Axel Libori Roch
banner
axliro.bsky.social
Axel Libori Roch
@axliro.bsky.social
Father of one 🧑, wheelchair user ♿, Backend developer, Laravel lover, code addict and author of https://paternitatsobrerodes.cat/

https://axliro.dev
The highest level of PHPStan!
September 12, 2025 at 7:10 PM
🔄 In Laravel, you can validate related booleans.
Using boolean + accepted_if, you can require that at least one is true when the other is false. Perfect for cases like "online" vs "in person".
#Laravel #PHP #Validation
August 5, 2025 at 6:25 PM
Using Laravel and have first_name and last_name in separate columns? You can still filter by full name using a subquery with CONCAT. Handy trick when you need flexible name searches!
#Laravel #PHP
July 29, 2025 at 5:53 PM
💡 When you only need to verify part of the JSON response in a test, use assertJsonFragment.
It’s great for making your tests more robust and less fragile to payload changes.
#Laravel #PHP #Testing
July 18, 2025 at 7:05 PM
💡 Did you know you can add multiple columns after another one in a single call with Laravel?
It's clean, elegant, and keeps your DB tidy.
Thanks Povilas Korop for the tip!
#Laravel #PHP #LaravelTips
July 14, 2025 at 3:46 PM
In Laravel 11, the implicit per_page handling in paginate() became explicit. One way to bring back that magic is by using the Context facade.
#Laravel #PHP #Laravel11 #WebDev #Backend
July 3, 2025 at 5:47 PM
🔥 Nova tip: Want to search by full name? Use DB::raw in searchableColumns()!
Now you can search for "John Doe" like a pro. 🧙‍♂️
#Laravel #LaravelNova #PHP
July 1, 2025 at 5:41 PM
📌 Laravel tip:
Keep your app timezone and display timezone separate.
This idea is from the @benholmen.com @laravelnews.com YouTube channel: store everything in UTC, display it in your preferred local timezone.
Great for clarity and consistency!
#Laravel #PHP #Carbon
June 20, 2025 at 7:13 PM
When interacting with external services (APIs, SMS, etc.), you don’t always want to run the job. With dispatchIf, you can conditionally dispatch it in a clean and elegant way. Perfect to avoid unnecessary calls.
#Laravel #CleanCode
June 16, 2025 at 3:41 PM
The second parameter of DB::transaction() is the retry count. Laravel will try the whole thing up to 5 times before giving up.
#Laravel #PHP #WebDev
June 13, 2025 at 2:58 PM
When configuring read/write MySQL connections, add 'sticky' => true to avoid inconsistencies!
With this, reads go to the write host right after a write, ensuring fresh data is returned.
#Laravel #PHP #MySQL
June 11, 2025 at 3:38 PM
🔄 Laravel supports splitting read & write DB connections, perfect for scaling with read replicas!
Note: You’re responsible for setting up the replication, Laravel just knows how to use it.
Docs 👉 laravel.com/docs/12.x/da...
#Laravel #PHP #Scalability
June 10, 2025 at 4:40 PM
💡 Want to filter an array by keys in PHP?
👀 You can use array_filter(..., ARRAY_FILTER_USE_KEY)
⚡️ But with Laravel, Arr::only() makes it much cleaner and more readable.
#LaravelTips #PHP #CleanCode
June 3, 2025 at 5:50 PM
Using action([Controller::class, 'method']) in endpoint tests gives you more robustness than hardcoding the route. If the URL changes but the controller doesn’t, your tests still work 💪 #Laravel #Testing
June 2, 2025 at 4:05 PM
🚨 Laravel tip: Want to send notifications to a different email based on the type?
With routeNotificationForMail(), you can redirect specific notifications to custom addresses.
👨‍👩‍👧‍👦 Parents get the truancy alerts, not the student 😉
#LaravelTips #PHP
May 26, 2025 at 3:53 PM
🔥 Give your fake users fake photos!
This code grabs images from thispersondoesnotexist.com and stores them in Storage.
Perfect for testing with realistic avatars 🤖📸
#Laravel #PHP #FakeData
May 23, 2025 at 3:19 PM
✨ If you're using Sanctum in your API and have a public endpoint, but want to detect if the caller is authenticated (e.g. to mark liked posts), you can do it without applying auth:sanctum — just check for the user manually.
#Laravel #Sanctum #API #PHP
May 19, 2025 at 4:51 PM
📌 Laravel tip: avoid N+1 issues by checking if a relationship is loaded before accessing it!
This hasContacts attribute only checks contacts if it's already loaded. Smart and efficient. 🧠
#Laravel #Eloquent #PHP #DevTips
May 14, 2025 at 4:51 PM
🔍 The pruning() method in Laravel runs right before a Prunable model gets deleted.
Perfect for cleaning up files or related data ahead of delete().
In this case, it deletes the file linked to an old Invoice.
#Laravel #PHP #LaravelTips
May 9, 2025 at 4:38 PM
🔧 Did you know Laravel has a trait called Prunable?
It lets you easily delete old models with a single method. Perfect for keeping your DB clean!
Schedule a command and... bye clutter! #LaravelTips #PHP
May 6, 2025 at 4:53 PM
🧐 Another use case for Laravel Model Observers: delete related files when a model is removed. Simple and effective.
#Laravel #PHP #ModelObserver #WebDev #Backend
May 4, 2025 at 3:22 PM
🔍 Need to transform model data before presenting it? @laravel.com accessors let you format values cleanly without touching the database. #Laravel #PHP
May 3, 2025 at 3:23 PM
🔄 A great use case for Laravel model observers: automatically clearing the cache when a model changes. This ensures we're always serving up-to-date data. #Laravel #PHP
May 1, 2025 at 7:22 AM
⚙️ Starting with Laravel 11, if for some reason you need to change the middleware order, you can do it in bootstrap/app.php.
#Laravel #PHP #LaravelTips
April 25, 2025 at 4:30 PM
📦 Laravel tip: Want to run different seeders based on the environment?

Use a DatabaseSeeder like this example:
✅ Always seed categories
🚫 Only seed mock admins & posts in non-production

Clean, safe, and environment-aware 💡 #Laravel #PHP
April 23, 2025 at 4:08 PM