I have a Laravel 5.6 project and am trying to update a post from a form like this
<input name="email" type="text" class="form-control" placeholder="Email" value="" required>
In my PostsController I have this...
if($request->input('email')) {
$user->email = $request->input('email');
}
I wanted it to only update the email if a new one has been input in the form, but because I am pre-populating the form fields it always passes the IF.
Is there a more Laravel way to do this? I have looked at isDirty() but I am not sure it is the correct thing to use.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire