| xqd
@@ -16,15 +16,21 @@ class OrganizationController extends AuthController
|
|
|
{
|
|
|
public function organizationList()
|
|
|
{
|
|
|
+ $req = request()->post();
|
|
|
$this->validate(request(), [
|
|
|
'latitude' => 'numeric',
|
|
|
'longitude' => 'numeric',
|
|
|
+ 'city_id' => 'integer',
|
|
|
]);
|
|
|
$user = $this->user;
|
|
|
|
|
|
$distance_field = get_user_distance_field($user);
|
|
|
|
|
|
- $data = Organization::with('docter')->select(['id', 'type', 'name', 'province_id', 'city_id', 'area_id', 'address', 'latitude', 'longitude', DB::raw($distance_field)])->orderBy('distance', 'asc')->paginate();
|
|
|
+ $builder = Organization::with('docter')->select(['id', 'type', 'name', 'province_id', 'city_id', 'area_id', 'address', 'latitude', 'longitude', DB::raw($distance_field)]);
|
|
|
+ if (!empty($req['city_id'])) {
|
|
|
+ $builder->where('city_id', $req['city_id']);
|
|
|
+ }
|
|
|
+ $data = $builder->orderBy('distance', 'asc')->paginate();
|
|
|
|
|
|
return out($data);
|
|
|
}
|