コード例 #1
0
 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);
 }
コード例 #2
0
 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];
 }