{ Laravel snippets }

🔥 If you're allowing a ?perPage= query param to be specified for your pagination results, LIMIT it! Particularly if you have a huge number of potential records. You can do this easily with the native min() PHP function. https://t.co/aNW7K09Zdt

Liam Hammett

Liam Hammett @LiamHammett

🔥 Sometimes, when using factories to seed random data, I might use a little random check to use an existing model for some relationships so not everything ends up creating new models for its own relations. It helps seeded data feel a lot more realistic to use. https://t.co/4GboYEfmcM

Tim MacDonald

Tim MacDonald @timacdonald87

🍭 You can utilise the Illuminate\Support Str + Arr classes in views without importing them No need to reach for a fully qualified name or the str_ / arr_ helpers They are defined as an alias in config/app.php which makes them available in the root namespace They just work™️ https://t.co/gUcutOebUL

Liam Hammett

Liam Hammett @LiamHammett

🔥 I often find myself keeping validation rules in a method on the model. This lets me reuse them wherever I may need - including in controllers or form requests. https://t.co/QDjYFEN2vM

Andrew Schmelyun

Andrew Schmelyun @aschmelyun

Me: *dreads having to rename a database table in my code* Laravel documentation:✨ It's just Schema::rename('old_name', 'new_name') my dude ✨

Laravel Daily

Laravel Daily @DailyLaravel

#Laravel tip of the day: if you want to have active/inactive (or, in other words, banned/suspended) users in your database, just add this method into your LoginController, it will act like a Middleware. https://t.co/BiMhzFIElF

Jason McCreary

Jason McCreary @gonedark

🔥 Controllers often have the most code as they contain all the business logic. By leveraging native components and expressive methods, we can streamline our controllers while also improving readability. A huge win. Here are some examples of reducing common blocks of code: https://t.co/ZCZXG4iAqa

Jason Beggs

Jason Beggs @jasonlbeggs

🔥 Reminder: When testing with Laravel, you can use the from() method to automatically set a referer url. This allows you to test redirects that use the redirect()->back() helper. https://t.co/1ny0hrAY2c

Stefan Bauer

Stefan Bauer @stefanbauerme

🌟 I'm working on a little feature at the moment and I thought it might be worth sharing. Another tip when you need to work with time intervals and seconds. Using `CarbonInterval` makes it much more readable. https://t.co/ktpNR7BoKY

Taylor Otwell 🏝

Taylor Otwell 🏝 @taylorotwell

This is something I don't think we document well enough. If you prefer a "Models" directory... you can do things like php artisan make:policy PhotoPolicy --model=Models/Photo.... php artisan make:model Models/Photo... etc. All works fine! 🥰 https://t.co/ZykVwAbpgH