A new "Conditionable" trait is available in Laravel. Some Laravel classes such as the query builder already offered "when" and "unless" methods for conditionally executing a callback chain. Now you can easily add this feature to your own classes! 🔥
I've started using random days in my Laravel factories. Since Carbon is already included, it's easy to do something like the below and generate posts created within the last 30 days.
🔥 If you use @laravelphp Valet, run the `valet trust` command to update your sudoers so you don't have to enter your password every time you run a Valet command.
Just prevent lazy loading in your Laravel projects that will save you of even unknown cases. Thanks to that, I realized I wasn't "eager loading" some relationships in my test suite. Thanks, @themsaid, for such a great addition to the framework.
The @inertiajs form helper now has an `isDirty` property, making it really easy to check if any form values have changed. One great use case for this feature is showing a message to the user making them aware when they have unsaved form changes. https://t.co/SpkR03P7JM
Many Laravel devs miss this. using DB validation rules like `exists` or `unique` for items of an array results in n number of DB queries. Better to fire single whereIn query and check the count.
You need to constantly check if a user is an admin on your Laravel views? Create an "admin" directive and save some extra lines of code every time:
Be careful with the __construct on your Laravel commands. Any instruction in there will be executed every time you call *any* command (it does not matter what command it is).
✉ If you have a multi-language project in Laravel, remember to specify the locale when sending your mailables:
Probably you know, but just in case: When testing your Laravel applications, use fast/dummy cache, session, queue, mail and, database drivers by configuring your phpunit.xml 👇👇
Just discovered that @laravelphp Nova has an as-you-type Slug field! I built my own previously, but now I can swap it out ✌️ p.s. Read documentation periodically.