samedi 11 novembre 2017

Laravel 5 İt's not saving to database but there is no error?

I'm using laravel 5.5 and try to save my blog post's comments to the database. When I tried this, it's not saving to database and not give any error ?

(I add a new comment, click send, redirect me same page. But not save comment to database..)

Controller

 public function store(Request $request, $post_id)
{
    $this->validate($request, [
        'name' => 'required',
        'email' => 'required',
        'comment' => 'required'
    ]);

    $post = Post::find($post_id);

    $comment = new Comment;
    $comment->name = $request->name;
    $comment->email = $request->email;
    $comment->comment = $request->comment;
    $comment->approved = true;
    $comment->posts()->associate($post);
    $comment->save;

    return redirect()->route('post_slug',$post->slug);

}

Where do I mistake ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zz51sF
via IFTTT

Aucun commentaire:

Enregistrer un commentaire