While inserting data in Mysql I have encountered the following error:
"Add [title] to the fillable property to allow mass assignment on [App\Post]."
Here is my code:
$post = Post::create([
'title' => $request->input('title'),
'body' => $request->input('body')
]);
While when I use another way to insert data, it is working fine: Following code is working fine :
//Create Post
$post = new Post;
$post->title = $request->input('title');
$post->body = $request->input('body');
$post->save();
Could anyone explain why an upper portion of the code is throwing an error?