Answer the question
In order to leave comments, you need to log in
How to resolve "Call to a member function on null" error?
Controller method:
public function update(Request $request, $id)
{
$this->validate($request, [
...
]);
Blog::find($id)->update($request->all());
return redirect()->route('blog.index')
->with('success','Blog updated successfully');
}
Call to a member function update() on null
var_dump($request)
Answer the question
In order to leave comments, you need to log in
Blog::find($id)
returns null, check if the blog exists
$blog = Blog::find($id);
if (isset($blog)) $blog->update($request->all());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question