with('finalLocation')->get(); $vehicles->each(function ($vehicle) { if (isset($vehicle->vin)) { $vehicle->vin = $this->maskVin($vehicle->vin); } }); $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); } }