Laravel Pro Tips
#validation
⚡️In Laravel 9 you can use the :position placeholder in validation messages if you're working with arrays. This will output: "Please provide an amount for price #2"
Martin Joo
#eloquent #mutators
📝 #Laravel Tip | Keeping the data in the database clear by using "Mutators". Regardless of how dirty the input of the user is 😱, it will be stored and returned cleanly. 🔥😎 #optimalisation #code #laraveltip #php #cleandata
Bert De Swaef
#directives #environments #env
#Laravel Tip 🔥 You may use "env" directive to check the running environment of the application You can also specify the array in "env" directive to check the multiple environments.
Gurmandeep Singh
#database #indexes
⚡️ Database Tip Creating indexes is a handcraft learned from experience, multiple-column indexes is a lot more complicated. But it doesn't have to be complicated! Here are 3 simple rules for the column ordering of multiple column indexes, solving 80% of the perf problems.
Tobias_Petry.sql
#routes
Use the ->where(‘parameter’, ‘.*’) method as a catch-all behavior for a route namespace to send everything into your route parameter. Just be aware of the order you register the routes! A tip from @AdrianrDev. #Laravel #PHP
Kirschbaum Development
#scopes #dates
Laravel Tip: Very often you need to filter the Model records based on created_date. 👉You can create scope Methods after() and before() and use them like below. 🔥 If multiple of your Models needs these methods, you can move them to Trait.
The Laravel Dev
#macros
#Laravel Tip: Don't repeat yourself in migrations. Many applications are tracking which user created and updated a model and have 2 columns for it. Don't write these 2 columns on every migration.Use a macro instead.
Jamil Soufan
#eloquent #models
🔥 Different properties that you pass to eloquent model in #Laravel
Sanjit Singh
#models #traits
On your #laravel models, keep them clean, with only the native public methods, like relationships, Mutators, ... And if you need to extend your Model logic with business methods, then you can create a "Services" Trait for that 👇
Bruno Falcão 🚀