/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $vehicle = Vehicle::findOrFail($id); $license_types = VehicleType::find($vehicle->vehicle_type_id)->license_types->toArray(); $vehicle_types = VehicleType::all()->toArray(); $vehicle_type_options = array(); if (!empty($vehicle_types)) { foreach ($vehicle_types as $vehicle_type) { $vehicle_type_options[$vehicle_type['id']] = $vehicle_type['type']; } } $license_type_options = array(); if (!empty($license_types)) { foreach ($license_types as $license_type) { $license_type_options[$license_type['id']] = $license_type['type']; } } $clients = User::select('id', 'first_name', 'last_name')->where('user_role', '=', '2')->get()->toArray(); $client_options = array(); if (!empty($clients)) { foreach ($clients as $client) { $client_options[$client['id']] = $client['first_name'] . " " . $client['last_name']; } } $license_type_arr = array(); $license_types = Vehicle::find($id)->license_types->toArray(); if (!empty($license_types)) { foreach ($license_types as $license_type) { $license_type_arr[] = $license_type['id']; } } return view('vehicle.update', compact('vehicle', 'vehicle_type_options', 'license_type_options', 'client_options', 'license_type_arr')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $license_type_arr = array(); $license_types = VehicleType::find($id)->license_types->toArray(); if (!empty($license_types)) { foreach ($license_types as $license_type) { $license_type_arr[] = $license_type['id']; } } $type = VehicleType::find($id); $options = array(); $license_types = LicenseType::all(); if (!empty($license_types)) { foreach ($license_types as $license_type) { $options[$license_type->id] = $license_type->type; } } return view('vehicle_types.update', compact('type', 'options', 'license_type_arr')); }