lundi 24 octobre 2016

Laravel eloquent updating tinyint (boolean)

I have a weird issue when updating eloquent model, I use a checkbox (1 || undefined ) and patch all the data after validation using

    $input = $request->all();
    $service->update($input);

I tried to check the checkbox specifically

    $input['active'] = ($request->has('active') && $input['active']) ? 1 : 0

but it still wouldn't affect the database.

When I dump the Request I can see active: 1 or 0 but nothing of that changes the database on update()

I did a quick testing and using

    $service->active = ($request->has('active') && $input['active']) ? 1 : 0 ;
    $service->save();

did the job. But why the update() isn't updating this field ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire