Likes()->get(); return response()->json([ 'data' => $like, 'message'=>'ok', 'status' => 200 ]); } function like(Request $request){ $like = Like::firstOrCreate([ 'user_id'=>Auth::user()->id, 'likable_id'=>$request->likable_id, 'likable_type'=>$request->likable_type, ]); if($like->wasRecentlyCreated){ }else{ $like->delete(); } return response()->json([ 'data' => true, 'message'=>'ok', 'status' => 200 ]); } }