Laravel Pro Tips
#models #traits
πΆοΈ #Laravel Tip: ππ§πππ©π¨ allows us to share code among Classes & specifically ππ€πππ‘π¨. You can seamlessly integrate with the Model booting & initialization process using traits. β Statically via boot{Trait} β Dynamically via initialize{Trait}
Bilal Haidar
#validation #csrf
#Laravel Tip π₯ You can exclude the CSRF verification by inserting the URL in $except array of VerifyCsrfToken Middleware.
Gurmandeep Singh
#eloquent #scopes
π₯ #Laravel Tip: Make use of local scopes in your Eloquent models in order to make your queries much easier to understand at a glance.
Matt Kingshott
#exceptions
π‘ A nice, undocumented feature of @laravelphp: you can βmapβ exceptions from one type to another in your exception handler. Nice for converting βdomainβ exceptions to a more appropriate HTTP exception #Laravel
Martin Bean
#redirects
#Laravel Quick Tip π₯ : Sometimes you want to redirect the user to previous page. There are couple of ways to do in Laravel. #PHP #100DaysOfCode #webdevelopers #developers
Mohammad Haris β‘
#performance #database #indexes
#Laravel #Eloquent Advice: If you are making queries by adding a where condition on a string based column, it is better to add an index to the column. Queries are much faster when querying rows with an index column. #Laravel #Database #PHP
Laravel Eloquent
#cache
πΆοΈ #Laravel tip: Laravel caching comes in handy especially when you are serving some static pages or static data. For instance, serving a list of countries, that rarely changes! #PHP #Developers
#eloquent #models #collections
π₯ Quick #Laravel Tip - If you have to return the primary keys for all models in the collection, instead of using `pluck()->toArray()` you can use `modelKeys()`
Marian Pop πΊπ¦ Laravel Magazine
#eloquent #memory
π₯ #Laravel #Eloquent Advice: Your application may run out of memory if you attempt to load large group of #Eloquent records via the `all` or `get` methods. Instead, chunk method may be used to process large numbers of models more efficiently. #Laravel #Databse #PHP