mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update ApiController
This commit is contained in:
parent
32d7ab091d
commit
460433ff20
1 changed files with 21 additions and 0 deletions
|
@ -6,6 +6,7 @@ use App\Http\Controllers\Api\BaseApiController;
|
||||||
use App\{
|
use App\{
|
||||||
Follower,
|
Follower,
|
||||||
Like,
|
Like,
|
||||||
|
Place,
|
||||||
Profile,
|
Profile,
|
||||||
UserFilter
|
UserFilter
|
||||||
};
|
};
|
||||||
|
@ -78,4 +79,24 @@ class ApiController extends BaseApiController
|
||||||
return response()->json($res->all());
|
return response()->json($res->all());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function composeLocationSearch(Request $request)
|
||||||
|
{
|
||||||
|
$this->validate($request, [
|
||||||
|
'q' => 'required|string'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$places = Place::where('name', 'like', '%' . $request->input('q') . '%')
|
||||||
|
->take(25)
|
||||||
|
->get()
|
||||||
|
->map(function($r) {
|
||||||
|
return [
|
||||||
|
'id' => $r->id,
|
||||||
|
'name' => $r->name,
|
||||||
|
'country' => $r->country,
|
||||||
|
'url' => $r->url()
|
||||||
|
];
|
||||||
|
});
|
||||||
|
return $places;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue