@@ -11,7 +11,7 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | public function up(): void |
| 13 | 13 | { |
| 14 | - Schema::create('regions', function (Blueprint $table) { |
|
| 14 | + Schema::create('regions', function(Blueprint $table) { |
|
| 15 | 15 | $table->id(); |
| 16 | 16 | $table->string('name')->comment('社区名称'); |
| 17 | 17 | $table->string('city_code')->comment("城市代码"); |
@@ -8,7 +8,6 @@ |
||
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Region Model |
| 11 | - |
|
| 12 | 11 | * @author Dennis Lui <[email protected]> |
| 13 | 12 | * |
| 14 | 13 | * @property string $id 主键 |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public static function bootRegionTrait() |
| 29 | 29 | { |
| 30 | - static::deleting(function ($model) { |
|
| 30 | + static::deleting(function($model) { |
|
| 31 | 31 | $model->region->each(fn(Region $region) => $region->delete()); |
| 32 | 32 | }); |
| 33 | 33 | } |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | * @param array $codes |
| 48 | 48 | * @return mixed |
| 49 | 49 | */ |
| 50 | - public function scopeWithGeoDistance($query, float $lat,float $lng,int $distance = 5000) |
|
| 50 | + public function scopeWithGeoDistance($query, float $lat, float $lng, int $distance = 5000) |
|
| 51 | 51 | { |
| 52 | 52 | $raw = "ST_Distance_Sphere(geo,ST_GeomFromText('POINT($lng $lat)',4326))"; |
| 53 | - return $query->whereHas('region', function ($q) use ($raw,$distance) { |
|
| 54 | - $q->select(DB::raw($raw.' as distance'))->where("distance <= $distance"); |
|
| 53 | + return $query->whereHas('region', function($q) use ($raw, $distance) { |
|
| 54 | + $q->select(DB::raw($raw . ' as distance'))->where("distance <= $distance"); |
|
| 55 | 55 | }); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | { |
| 56 | 56 | $this->selectDistance($service, $lat, $lng, $column); |
| 57 | 57 | $distanceRaw = $this->distanceRaw($lat, $lng, $column); |
| 58 | - $service->setQuery(function (Builder $query) use ($distanceRaw, $maxDistance) { |
|
| 58 | + $service->setQuery(function(Builder $query) use ($distanceRaw, $maxDistance) { |
|
| 59 | 59 | $query->whereRaw("$distanceRaw <= $maxDistance"); |
| 60 | 60 | }); |
| 61 | 61 | return $service; |