app/Http/Controllers/CommentController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(CreateCommentRequest $request, $post_id)
    {
        $post = Post::find($post_id);
        $comment = new Comment();
            $comment->name = $request->name;
            $comment->email = $request->email;
            $comment->comment = $request->comment;
            $comment->approved = true;
            $comment->post()->associate($post);
        $comment->save();
        if (Auth::check()) {
            Log::info(Auth::user()->username . " (" . Auth::user()->id . ") commented on post (" . $post->id . ")\r\n", [json_decode($comment, true)]);
        } else {
            Log::info(Request::ip() . " commented on post " . $post->id);
        }
        Session::flash('success', 'Comment was added');
        return redirect()->route('blog.single', [$post->slug]);
    }
public function store ( CreateCommentRequest $ request , $ post_id ) { $ post = Post :: find ( $ post_id ) ; $ comment = new Comment ( ) ; $ comment -> name = $ request -> name ; $ comment -> email = $ request -> email ; $ comment -> comment = $ request -> comment ; $ comment -> approved = true ; $ comment -> post ( ) -> associate ( $ post ) ; $ comment -> save ( ) ; if ( Auth :: check ( ) ) { Log :: info ( Auth :: user ( ) -> username . "  ( " . Auth :: user ( ) -> id . " ) commented on post ( " . $ post -> id . " ) \r \n " , [ json_decode ( $ comment , true ) ] ) ; } else { Log :: info ( Request :: ip ( ) . "  commented on post  " . $ post -> id ) ; } Session :: flash ( 'success' , 'Comment was added' ) ; return redirect ( ) -> route ( 'blog.single' , [ $ post -> slug ] ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// Save entry to log file using built-in Monolog