app/Http/Controllers/PostCommentController.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(Request $request)
    {
        $post_info=Post::getPostBySlug($request->slug);
        $data=$request->all();
        $data['user_id']=$request->user()->id;
        $data['status']='active';
        $status=PostComment::create($data);
        $user=User::where('role','admin')->get();
        $details=[
            'title'=>"New Comment created",
            'actionURL'=>route('blog.detail',$post_info->slug),
            'fas'=>'fas fa-comment'
        ];
        Notification::send($user, new StatusNotification($details));
        if($status){
            request()->session()->flash('success','Thank you for your comment');
        }
        else{
            request()->session()->flash('error','Something went wrong! Please try again!!');
        }
        return redirect()->back();
    }
public function store ( Request $ request ) { $ post_info = Post :: getPostBySlug ( $ request -> slug ) ; $ data = $ request -> all ( ) ; $ data [ 'user_id' ] = $ request -> user ( ) -> id ; $ data [ 'status' ] = 'active' ; $ status = PostComment :: create ( $ data ) ; $ user = User :: where ( 'role' , 'admin' ) -> get ( ) ; $ details = [ 'title' => " New Comment created " , 'actionURL' => route ( 'blog.detail' , $ post_info -> slug ) , 'fas' => 'fas fa-comment' ] ; Notification :: send ( $ user , new StatusNotification ( $ details ) ) ; if ( $ status ) { request ( ) -> session ( ) -> flash ( 'success' , 'Thank you for your comment' ) ; } else { request ( ) -> session ( ) -> flash ( 'error' , 'Something went wrong! Please try again!!' ) ; } return redirect ( ) -> back ( ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
// return $request->all(); // return $post_info; // $data['post_id']=$post_info->id; // return $data;