Laravel Pro Tips
#services #actions
π‘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. π§΅Keep Reading
Martin Joo
#eloquent #sql #query builder
π₯ #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
#pagination
πΆοΈ #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
#eloquent #query builder
π₯ #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.
Matt Kingshott
#migrations #models
π₯ #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 Eloquent
#blade #directives
π₯ #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.
#eloquent #scopes #relationships
π₯ #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.
#faker
A quick one that I *always* forget about -- Faker::numerify, allowing you to generate numeric data in a specific pattern ππ
Steve Bauman π
#dates #accessors #mutators #timezones
πΆοΈ #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