#Laravel Validation Tip 🔥
You can use a closure instead of a rule object if you only need a custom rule once throughout your application.
The closure receives the attribute's name, the attribute's value, and a `fail` callback that should be called if validation fails. https://t.co/Bl0EkmArzu
💡 You can define HTTP macro to configure common request paths and headers when interacting with services throughout your application.
#laravel #laravelphp #laraveltips #laraveltricks #laravelupdates #laravelfeatures https://t.co/eN8mcRWHl8
🔥 #Laravel Tip: A common pattern in websites that offer searchable content, is to suggest content when the user's query returns no results. Laravel can help with this via the 'existsOr' method. Here's an example that finds an alternative vacation destination. https://t.co/dvYvcJIuNr
Use `whereBetween` method, if you want to get data between two timeframes from a specific column.
Here is an example: https://t.co/9OgcAFQkXl
I just discovered that you could add opacity to HEX colours (as opposed to RGBA) 🤯🤯
You have your initial colour, e.g. #FFAABB
You want to add opacity? Add two more hex chars. e.g. #FFAABB99
The last two chars will control opacity from 00 (0) to FF (1).
🔥 #Laravel Tip: When accessing APIs, consider using a unique user agent. That way, if there's a problem, the owner of the API can see who you are and get in touch. It doesn’t guarantee they will, but you might be lucky and avoid being blocked. https://t.co/cJsLiQSojH
🔥 #Laravel Tip: Instructing the database to delete a huge number of records is likely to make it fall over (esp. when using cascade deletion). However, you can avoid this by staggering the process into batches and adding pauses to allow the database time to catch up. https://t.co/xkv0If70ac
🔥 #Laravel Tip: A common task when performing an authorisation check, is to verify if a particular model (such as the authenticated user) owns another model (e.g. a blog post). Since you're likely to do this a lot, consider adding an 'Ownership' trait to your models: https://t.co/U5ZPfAm9PS
Another piece of Laravel smoothness 🏄
Did you know that you can use *whereBelongsTo* instead of a regular *where*? 🍃 https://t.co/FdjPA3nbqV
🔥 #Laravel Tip: When storing database notifications, you may want to avoid adding duplicates, so that a user's “feed” only contains unique content. You can do this by adding a hash of the content and then enforcing a unique constraint on the table. https://t.co/ahbbMYxsA8