Support the ongoing development of Laravel.io →
Database Forms Validation

Hi,

When I save a model, I want to validate its contents; I use a validator and a protected array of $rules. This works perfectly fine.

However, once saved I also need to trigger some updates. Other models, caches, the works.

So when I do this:

$result = $newAccount->save();

The trigger kicks in. If the trigger returns false because something fails, that's ok. But I cannot access the validation errors. I just get back false. So I'm forced to do this in two steps; first validate, then fire the trigger. Which could still return false.

Is there a way to combine this?

$result = $newAccount->save();
if($result) {
    //redirect
} else {
    // somehow get the validation errors
    // send back with input
}
Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

JC5 jc5 Joined 24 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.