public function chkUserLike(Request $request) { $like = PostLike::where('postId', $request->postId)->where('userId', $request->userId)->first(); if ($like) { return response()->json(true); } return response()->json(false); }
public function search($input) { $query = PostLike::query(); $columns = Schema::getColumnListing('postLikes'); $attributes = array(); foreach ($columns as $attribute) { if (isset($input[$attribute]) and !empty($input[$attribute])) { $query->where($attribute, $input[$attribute]); $attributes[$attribute] = $input[$attribute]; } else { $attributes[$attribute] = null; } } return [$query->get(), $attributes]; }