💡When I need to work with date filters I often add a simple DateFilter class with static factory functions.
It's a very simple yet clean and resuable solution:
🔒#Laravel Tip: When storing JSON data in database columns, validate the fields within JSON arrays using Laravel's validation rules. (Don't forget to cast your attributes)
Use the wildcard (*) syntax to apply rules to each element. Protect your data's integrity and security.
Some Laravel developers started using DTOs instead of custom form requests.
Did you? Because I'm thinking about it. 🤔
Spatie even has a package for that (spatie/laravel-data). 👌
@worksfess Pertama, kamu harus tau interest di hal yang mana sama IT. misal kamu suka design, nah menurutku kamu bisa ke UI/UX. Untuk mulai dari mana, aku prefer kamu harus pahamin tipe data dasar pemrograman. Kalo mau tanya tanya sabi dm
#Laravel Tip: Optimize database performance by utilizing Laravel's query caching. By caching frequently executed queries, that are not meant to change for a while, you can reduce database load and speed up your application.
We're super-happy to announce Backpack v6 (July 2023) will support @spatie_be 's MediaLibrary package, with a first-party add-on.
It's super simple:
- install and configure spatie/laravel-medialibrary
- install backpack/medialibrary-uploaders
Then do this. It's that simple!
⚡You can do some pretty cool stuff with enums in PHP and Laravel. In this thread, I’ve collected some of the useful stuff, such as:
- Backed enums
- Using enums as factories
- Validation
- Enum route binding
- Model attribute casts
🧵Keep Reading
#Laravel Tip You can use `mapWithKeys` method The mapWithKeys method iterates through the collection and passes each value to the given callback. The callback should return an associative array containing a single key / value pair
#laravel#laravelphp#php
⚡️ 2-in-1 #Laravel tips here for you!
- You can create a basic filter for your APIs without any package. #Eloquent scopes are quite powerful!
- When using when() 🙂, most times, you do not need a closure.
It's a shame that Apple doesn't allow interpreters to run on apps distributed via the App Store, or we could have been building Laravel apps for mobile at this point. 🤔
I think the closest we can get currently is something like https://t.co/LCwVC7wOxO and run progressive web apps.
Still, just having this on desktops is already a really cool thing that was just a theoretical a week ago. Mad props to @marcelpociot and @simonhamp for their work on this.
Two commonly used #laravel methods for Form Request classes.
prepareForValidation() - prepare or sanitize any data from the request before you apply your validation rules.
passedValidation() - normalize any request data after validation is complete.
#laraveltips#laraveldevs
⚡️ Database Tip
When doing statistical aggregations by time, you may have e.g. days without data leading to strange results when charting the results. But you don't have to fill these gaps manually with code, the database can do that for you.
https://t.co/4QGB7HZBxA
Tomorrow, a spicy version of the @OpenAI PHP API client will be released. If you're a fan of testing, you're gonna love it! ❤️🔥 https://t.co/7Gw0fewTI5