with('finalLocation')->get(); $vehicles->each(function ($vehicle) { if (isset($vehicle->vin)) { $vehicle->vin = $this->maskVin($vehicle->vin); } $vehicle->status = $this->status[$vehicle->status]??$this->status[0]; // $location = Location::find($vehicle->locations_id); // $vehicle->location_name = $location ? $location->name : ''; // $final_location = Location::find($vehicle->final_locations_id); // $vehicle->final_location_name = $final_location ? $final_location->name : ''; $fbo_location = Location::find($vehicle->fbo_locations_id); $vehicle->fbo_destination = $fbo_location ? $fbo_location->name : ''; if(!str_starts_with($vehicle->url, 'http')){ $ossservice = new OssService(); $img_url = $ossservice->generatePrivateUrl($vehicle->img_url,86400); $vehicle->img_url = $img_url; } }); $result = ['list' => $vehicles,'count'=>count($vehicles)]; return Util::success($result); } /** * Get a specific vehicle with its location */ public function show(Request $request, $id) { $vehicle = Vehicle::with('location')->find($id); if (!$vehicle) { return Util::fail($vehicle,'Vehicle not found'); } if (isset($vehicle->vin)) { $vehicle->vin = $this->maskVin($vehicle->vin); } return Util::success($vehicle); } }