Update SearchController, fix self search bug and rank local matches first

This commit is contained in:
Daniel Supernault 2020-04-28 02:42:21 -06:00
parent bc22de3545
commit f67fada273
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -194,11 +194,14 @@ class SearchController extends Controller
else {
$this->tokens['profiles'] = Cache::remember($key, $ttl, function() use($tag) {
$users = Profile::select('domain', 'username', 'name', 'id')
if(Str::startsWith($tag, '@')) {
$tag = substr($tag, 1);
}
$users = Profile::select('status', 'domain', 'username', 'name', 'id')
->whereNull('status')
->where('id', '!=', Auth::user()->profile->id)
->where('username', 'like', '%'.$tag.'%')
->limit(20)
->orderBy('domain')
->get();
if($users->count() > 0) {