Laravel Pro Tips
#eloquent
Laravel Tip 💡 Starting Laravel 9.4 you can return a column from the sole value instead of the whole record.
Philo Hermans
#composer
🔥 Composer can do more than requiring packages. Here are some commands I regularly use. - `composer outdated` (shows outdated packages) - `composer show` (shows all installed packages, -t as tree) - `composer why / why-not` (tells you why it depends (or not) on another package
Stefan Bauer
#eloquent #cache
When caching query results in Laravel, you can do this little trick to flush the cache when you're creating or updating a model ✨
Daniel Eckermann
#validation #database
#Laravel Tip💡 You can validate the uniqueness of a DB column for a particular user. Let's say, the posts table has slug and user_id, and slug must be unique per user_id. i.e. composite unique key of slug and user_id
Ryuta Hamasaki
#accessors #datetime
🔥 In your Laravel apps, you can sometimes use DATETIME fields instead of booleans. By doing this, you can still check for boolean values (using an accessor) and get to store extra datetime information that might be useful in your app later. #laravel #php
Ash Allen 🚀
#responses
When you don't have anything to return in the response of any request you can simply return the response with noContent() method in #Laravel. See how can you do that 👇 #PHP #HTTP #webdevelopers #100DaysOfCode #developers #100Devs
Mohammad Haris ⚡
#responses #exceptions
🌶️ #Laravel Tip: I like to use the helper functions `abort`, `abort_if`, `abort_unless` to throw HTTP Exceptions. There is also `throw_if` and `throw_unless` to throw a RuntimeException in your code. #PHP #Developers #100Devs
Bilal Haidar
#models #properties
#Laravel #Eloquent Tip: There are useful “parameters” of an Eloquent model, in the form of properties of that class. And there’s even more, I’ve listed the most interesting ones, for more https://t.co/JFUsCCuSJO #Laravel #Database #PHP
Laravel Eloquent
#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