Answer the question
In order to leave comments, you need to log in
How to update only those values that came in?
Tell me how in laravel to update only those values that came in?
There is for example a model with such fields:
title | description | body
I know that you can update it like this:
$post = Post::find($id);
$post->title = '...';
$post->description = '...';
$post->body = '...';
$post->save();
Answer the question
In order to leave comments, you need to log in
$post->fill($request->validated())->save()
Of course, you either need to add fields to the fillable or use forceFill.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question