/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'title',
'slug',
'body',
'image',
'published',
'comments_open'
];
$model = new Demo();
dd($model->getFillable());
//for comment Section
//commentController.php
public function store(StoreCommentRequest $request)
{
//
$comment = Comment::create([
"message"=>$request->message,
"post_id"=>$request->post_id,
"user_id"=>Auth::id(),
]);
return redirect()->to(url()->previous()."#comment-create");
}
//Comment.php <= model
class Comment extends Model
{
use HasFactory;
protected $fillable =["message","user_id","post_id"];
}