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
Back