mardi 7 avril 2020

Laravel validateForm: prevent update when inactive

I'm trying to prevent an update in a record when the function isActive returns false.

Foo.php

// My Class

public function isActive() {
    return false;
}

FooForm.php

// My Form

public function validateForm()
{
    $this->validate($this->request, [
        'field_1'      => 'required',
        'field_2'      => 'required',
        'field_3'      => 'required',
        'isActive' => 'boolean:true'
    ]);
}

Expected: Block the update because isActive returns false.

Nowadays: Updating without any problem.

EDIT

isActive can't be database property.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire