Laravel Pro Tips
💡This is a simple service class.
It helps you:
- Simplifying your overcomplicated controllers
- Extracting out reusable code
They can be really useful in smaller projects.
🔥 #Laravel Eloquent Tip - You can use "as" in Eloquent Query Builder to return any column with a new name, exactly like in a regular SQL query.
Marian Pop 🇺🇦 Laravel Magazine
🌶️ #Laravel tip: When you want to paginate your data results & only show "Next" and "Previous" buttons, you can opt for "simplePaginate()" instead of "paginate()" method.
In this case, simplePaginate() is more efficient 👍
#PHP #Developers #100Devs
Bilal Haidar - Available 4 Laravel gigs
🔥 #Laravel Tip: Make use of the ‘value’ method on the query builder to execute a more efficient query when you only need to retrieve a single column.
🔥 #Laravel Tip: you can define default values for columns in two places: Migrations and models.
Via Models you can specify default attribute values and change them time by time only in code level, while in migration you need to write extra migration.
#Laravel $Tip #Php
🔥 #Laravel Tip: Version 9 of the framework includes the new @checked and @selected directives for use in Blade templates. They are a nice addition that makes it easier to define whether a checkbox is checked, or which value a dropdown should be set to.
🔥 #Laravel Tip: Data leakage from incorrectly scoped queries is a major problem. One way of reducing the risk of it happening, is to always define and use relationship methods on your models. That way they will be automatically scoped.
A quick one that I *always* forget about -- Faker::numerify, allowing you to generate numeric data in a specific pattern 👌👏
Steve Bauman 💎
🌶️ #Laravel Tip: Use Laravel Accessor/Mutator to 𝘀𝗲𝘁 Date field in UTC and 𝗴𝗲𝘁 Date field in user's current Timezone.
Working with dates with timezones is always tricky & challenging 💪
#PHP #Developers #100daysofcodechallenge