예제 #1
0
 /**
  * Find users by matching a string of words against their username,
  * optionally making sure they are visible to a certain user.
  *
  * @param  string  $string
  * @param  \Flarum\Core\Models\User|null  $user
  * @return array
  */
 public function getIdsForUsername($string, User $user = null)
 {
     $query = User::select('id')->where('username', 'like', '%' . $string . '%')->orderByRaw('username = ? desc', [$string])->orderByRaw('username like ? desc', [$string . '%']);
     return $this->scopeVisibleForUser($query, $user)->lists('id');
 }