app/Http/Controllers/api/v1/user/LikeController.php
// check if user like this post or not
check if user like this post or not
check if user like this post or not
public function show($id){
        $user = Auth::id();
        $likepost = Like::where([
            'user_id' =>  $user ,
            'post_id' =>  $id
        ]);
        $likes = DB::table('likes')
                ->where('post_id', '=', $id)
                ->where('user_id', '=', $user)
                ->get();
        if ($likes->count()){
            $status = 1;
            return jsonResponse($status , 'like' , 1);
        } else {
            $status = 1;
            return jsonResponse($status , 'unlike' , 0);
        };
    }
public function show ( $ id ) { $ user = Auth :: id ( ) ; $ likepost = Like :: where ( [ 'user_id' => $ user , 'post_id' => $ id ] ) ; $ likes = DB :: table ( 'likes' ) -> where ( 'post_id' , '=' , $ id ) -> where ( 'user_id' , '=' , $ user ) -> get ( ) ; if ( $ likes -> count ( ) ) { $ status = 1 ; return jsonResponse ( $ status , 'like' , 1 ) ; } else { $ status = 1 ; return jsonResponse ( $ status , 'unlike' , 0 ) ; } ; }
check if user like this post or not
check if user like this post or not