Ever assumed Laravel's after() method runs after validation passes?
Plot twist: it runs after validation completes - even when it fails 😅
Found this out when DB queries were hitting on invalid requests. Worse - got 500 errors when callbacks tried processing bad data.
Quick fix? Check if validator has errors first and bail early.
But real talk - DB queries don't belong in Form Requests. Keep validation fast, move heavy stuff to services.
dev.to/tegos/laravel-validation-after-after-what-exactly-28fa
🔧 Fixed Laravel Bug (and Got My PR Merged!)
Tried to delete 500 rows with batch... Laravel deleted 500,000+ at once 😅
Turns out, DELETE queries with JOIN + LIMIT/ORDER BY were dropping those clauses - wiping out way more than intended.
I patched it so Laravel now keeps the full query and lets MySQL handle errors properly.
Merged into Laravel 13.x 🎉
✅ No more silent mass deletions
🙌 Open source wins again
dev.to/tegos/battling-laravels-sneaky-deletes-how-i-got-order-by-and-limit-to-play-nice-with-joins-ng9
Laravel Performance Tip 🚀
Stop hitting the cache twice! Many devs do `Cache::has()` before `Cache::get()` - but that doubles the work for the same key.
Benchmarks say it all:
- ⏱ Execution: 14ms → 6ms
- 🧠 Memory: 47MB → 43MB
- 🔑 Cache calls: 2 → 1
✅ Fix: skip `has()`, just `get()` and check for null:
$value = Cache::get($key);
if ($value !== null) return $value;Tiny tweak, huge impact under load. Full examples and results in the article!
dev.to/tegos/laravel-cache-tip-avoid-redundant-hasmissing-calls-4hi1
#Laravel #PHP #LaravelTips
🚀 Optimized my Laravel vendor/ folder and cut it from 200.6 MB ➝ 119.8 MB (40% lighter) 🪶
Result: faster deploys, smaller Docker images, smoother CI/CD.
Inspired by @jclermont article on trimming the AWS SDK, I ran my own cleanup experiment and shared the steps here:
dev.to/tegos/optimize-vendor-folder-size-1m01
#Laravel #PHP #DevOps
🚀 Excited to share my take on taming business logic in Laravel with Actions & Services! 🛠️ Say goodbye to bloated controllers with my practical approach using OrderCreateAction for operations and DeliveryScheduleService for reusable logic. Check out tips, code examples, and a decision matrix to keep your Laravel projects clean and scalable. Inspired by @nunomaduro and others.
dev.to/tegos/laravel-actions-and-services-360d
#Laravel #PHP #LaravelTips