Пример #1
0
 /**
  * Suggest list of users in JSON
  * e.g. ['id' => 1, 'name' => 'User Name']
  *
  * @param null $candidate
  *
  * @return \Illuminate\Http\JsonResponse|void
  */
 public function suggest($candidate = null)
 {
     if (stristr($candidate, '@')) {
         $candidate = trim($candidate, '@');
     }
     $users = $this->repo->suggest('name', $candidate);
     if ($users) {
         return response()->json(['data' => $users->toArray()]);
     }
     return;
 }