{ Laravel snippets }

Philo Hermans

Philo Hermans @Philo01

Laravel productivity tip! Add this little function to your bash profile to quickly execute anything with the Tinker command and get the results instantly. https://t.co/qIB9pQCTWt

Michael Dyrynda 💉💉

Michael Dyrynda 💉💉 @michaeldyrynda

🔥 An important consideration when working with @laravelphp's environment and config tooling that bit me. Keys that exist in your `.env` file with no value will not fallback to the `env()` helper's default value. To achieve the desired outcome, use null coalescing instead. https://t.co/qptuGEPzMN

Jonathan Reinink

Jonathan Reinink @reinink

🔥 Ever wondered how to set active states on links in an @inertiajs app? It's actually really easy to do! 💁‍♂️ Simply do string comparisons against the `page.url` or `page.component` properties. You can do exact matches, or "startsWith" checks, or even regular expressions! https://t.co/Gc3I917bVJ

Bruno Falcão 🚀

Bruno Falcão 🚀 @brunocfalcao

🔥Laravel tip If you want to save an Eloquent model without triggering Eloquent Events use the method saveQuietly() $yourModel->saveQuietly() Lifesaver on model observers when you don't want to recursively trigger its own events (ending in an infinite loop)

The Laravel Dev

The Laravel Dev @TheLaravelDev

While adding a New Column to existing table using Migration, the column is always added at the last. ✅You can use the after() to place the New Column after a specific column. ✅You can also use the first() to place the New Column at the start of the table. #Laravel https://t.co/hNaiFuYZi5

Povilas Korop

Povilas Korop @PovilasKorop

Quick Laravel tip: if you want to have a custom validation rule but it's a short one-liner, you may specify it directly in the $rules array, as a callback function. https://t.co/su7vUvZTM4

Liam Hammett

Liam Hammett @LiamHammett

🔥 You don't need a closing tag when using the @​php directive in @laravelphp Blade, you can put some logic on a single line. It's especially nice to use it to do things like setting default values in a partial with the null-coalesce-assign operator. https://t.co/raQZBfPyxm

💡 in Laravel you can do things as the framework is terminating (after request has been processed!) You can do this in a middleware, using App::terminating with callback or natively with PHP using register_shutdown_function https://t.co/Z6tzN8jdkd

Liam Hammett

Liam Hammett @LiamHammett

🔥 With Laravel Mix, if you're building Sass files, you can pass a list of PostCSS plugins as the fourth parameter that will only apply to the given file. This is useful if you want one process to handle multiple things as usually the postCss method will apply to all CSS files https://t.co/B67M4kWOX4

Jason McCreary

Jason McCreary @gonedark

Piggybacking off the last 🔥 tip, most Blade templates simply use the `if` directive. However, there are so many more Blade directives available. These are not only more expressive, but often streamline the code. Here's a side-by-side comparison: https://t.co/Z2Edmf8kDO