app/Http/Controllers/ResponseController.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)
    {
        $request->validate([
            'response' => ['required'],
        ]);
        $review = ProductReviews::with('user')->where('id', $request->review_id)->first();
        $user = User::find($review->user_id);
        $response = new Response();
        $response->review_id = $request->review_id;
        $response->admin_id = $request->admin_id;
        $response->content = $request->response;
        $response->save();
        $admin = Admin::find(1);
        $data = [
            'nama'=> 'Admin',
            'message'=>'Response dikirim!',
            'id'=> $request->review_id,
            'category' => 'review'
        ];
        $data_encode = json_encode($data);
        $admin->createNotif($data_encode);
        $data = [
            'nama'=> $user->name,
            'message'=>'Review diresponse!',
            'id'=> $review->product_id,
            'category' => 'review'
        ];
        $data_encode = json_encode($data);
        $user->createNotifUser($data_encode);
        return redirect('/review');
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'response' => [ 'required' ] , ] ) ; $ review = ProductReviews :: with ( 'user' ) -> where ( 'id' , $ request -> review_id ) -> first ( ) ; $ user = User :: find ( $ review -> user_id ) ; $ response = new Response ( ) ; $ response -> review_id = $ request -> review_id ; $ response -> admin_id = $ request -> admin_id ; $ response -> content = $ request -> response ; $ response -> save ( ) ; $ admin = Admin :: find ( 1 ) ; $ data = [ 'nama' => 'Admin' , 'message' => 'Response dikirim!' , 'id' => $ request -> review_id , 'category' => 'review' ] ; $ data_encode = json_encode ( $ data ) ; $ admin -> createNotif ( $ data_encode ) ; $ data = [ 'nama' => $ user -> name , 'message' => 'Review diresponse!' , 'id' => $ review -> product_id , 'category' => 'review' ] ; $ data_encode = json_encode ( $ data ) ; $ user -> createNotifUser ( $ data_encode ) ; return redirect ( '/review' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//Notif Admin //Notif User