hasMany(Vehicle::class, 'locations_id', 'id'); } /** * 目的地关联 * Get the vehicles for the location. */ public function finalVehicles() { 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. */ public function scopeHasVehicles($query) { return $query->whereHas('vehicles'); } }