From 907490a4a546438612b4e63e410f33f4af6a5852 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Fri, 25 Apr 2025 16:54:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/LocationController.php | 2 ++ app/model/Location.php | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/app/controller/LocationController.php b/app/controller/LocationController.php index 7d738d9..9e6ed82 100644 --- a/app/controller/LocationController.php +++ b/app/controller/LocationController.php @@ -15,8 +15,10 @@ class LocationController { $locations = Location::hasVehicles() ->with('vehicles') + ->with('fboVehicles') ->get() ->map(function ($location) { + $location->fbo_vehicle_count = $location->fbo_vehicles->count(); $location->vehicle_count = $location->vehicles->count(); return $location; }); diff --git a/app/model/Location.php b/app/model/Location.php index 437ce9a..6d2c789 100644 --- a/app/model/Location.php +++ b/app/model/Location.php @@ -35,6 +35,7 @@ class Location extends Model return $this->hasMany(Vehicle::class, 'locations_id', 'id'); } /** + * 目的地关联 * Get the vehicles for the location. */ public function finalVehicles() @@ -42,6 +43,14 @@ class Location extends Model return $this->hasMany(Vehicle::class, 'final_locations_id', 'id'); } + /** + * Get the FBO vehicles for the location. + */ + public function fboVehicles() + { + return $this->hasMany(Vehicle::class, 'fbo_locations_id', 'id'); + } + /** * Scope a query to only include locations that have vehicles. */