/**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function update($id, VehicleRequest $request)
 {
     $vehicle = Vehicle::findOrFail($id);
     $vehicle->update($request->all());
     Session::flash('flash_message', 'Vehicle updated!');
     return redirect('camp/vehicles');
 }
Exemplo n.º 2
0
 /**
  * Check that the vehicle in the request belongs to the logged in user
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Callable  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $requestUri = $request->getRequestUri();
     $regex = '/^\\/.*\\/vehicle\\/(\\d+)\\/?.*/';
     $result = preg_match($regex, $requestUri, $matches);
     if ($result === 1) {
         $vehicleId = $matches[1];
         $userId = $request->user()->id;
         try {
             $vehicle = Vehicle::findOrFail($vehicleId);
         } catch (ModelNotFoundException $e) {
             return response("Not found", 404);
         }
         if ($vehicle->user_id !== $userId) {
             return response("Forbidden", 403);
         }
     }
     return $next($request);
 }
Exemplo n.º 3
0
 public function getAddFillupView(Request $request, $vehicleId)
 {
     $activeUser = $request->user();
     $vehicle = Vehicle::findOrFail($vehicleId);
     return view('fillup.create')->with(['activeUser' => $activeUser, 'vehicle' => $vehicle]);
 }
Exemplo n.º 4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(VehicleRequest $request, $id)
 {
     $vehicle = Vehicle::findOrFail($id);
     $vehicle->update($request->all());
     return redirect('vehicles');
 }
 /** vehicle license renewal request view */
 public function renewal_request($id)
 {
     $check = Vehicle::findOrFail($id);
     $vehicle = DB::table('vehicles')->join('vehicle_types', 'vehicle_types.id', '=', 'vehicles.vehicle_type_id')->select('vehicles.*', 'vehicle_types.type')->where('vehicles.id', $id)->first();
     /* $license_types = DB::table('license_types')
        ->join('license_type_vehicle','license_types.id', '=', 'license_type_vehicle.license_type_id')
        ->leftJoin('license_renewal_requests', 'license_type_vehicle.license_type_id', '=', 'license_renewal_requests.license_type_id')
        ->select('license_types.id as license_type_id','license_types.type', 'license_type_vehicle.license_start_on', 'license_type_vehicle.license_end_on','license_type_vehicle.id as license_type_vehicle_id','license_renewal_requests.status')
        ->where('license_type_vehicle.vehicle_id','=',$id)
        ->whereNull('license_type_vehicle.deleted_at')
        ->get();*/
     $license_types = DB::table('license_types')->join('license_type_vehicle', 'license_types.id', '=', 'license_type_vehicle.license_type_id')->select('license_types.id as license_type_id', 'license_types.type', 'license_type_vehicle.license_start_on', 'license_type_vehicle.license_end_on')->where('license_type_vehicle.vehicle_id', '=', $id)->whereNull('license_type_vehicle.deleted_at')->get();
     $renewal_request = DB::select(DB::raw("SELECT vehicle_id, license_type_id, status FROM( SELECT * FROM `license_renewal_requests` WHERE vehicle_id={$id} ORDER BY requested_on DESC) as inv GROUP BY license_type_id,vehicle_id"));
     $request = array();
     if (!empty($renewal_request)) {
         foreach ($renewal_request as $value) {
             $request[$value->license_type_id] = $value->status;
         }
     }
     return view('vehicle.renewal_request', compact('vehicle', 'license_types', 'request'));
 }
 /**  */
 public function update_license($id)
 {
     $license_types = Vehicle::findOrFail($id)->license_types->toArray();
     $license_type_arr = array();
     if (!empty($license_types)) {
         foreach ($license_types as $license_type) {
             $license_type_arr[$license_type['id']] = $license_type['type'];
         }
     }
     $vehicle_id = $id;
     return view('vehicle.update_license', compact('license_type_arr', 'vehicle_id'));
 }
Exemplo n.º 7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     try {
         $vehicle = Vehicle::findOrFail($id);
         $vehicle->delete();
         return response('', 204);
     } catch (ModelNotFoundException $e) {
         abort(404);
     }
 }
Exemplo n.º 8
0
 private function assertVehicleExists($vehicleId)
 {
     try {
         $vehicle = Vehicle::findOrFail($vehicleId);
     } catch (ModelNotFoundException $e) {
         abort(404);
     }
 }
Exemplo n.º 9
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $job = Job::findOrFail($id);
     //var_dump($job); die;
     $estimate = Estimate::findOrFail($job->estimate_id);
     $estimate_details = DB::table('estimate_details')->where('estimate_id', '=', $job->estimate_id)->get();
     $department = Department::findOrFail($estimate->department);
     $s_advisor_list = DB::table('stakeholders')->where('role', '=', 's_advisor')->lists('name', 'id');
     $sec_incharge_list = DB::table('stakeholders')->where('role', '=', 'sec_incharge')->lists('name', 'id');
     $customer = Customer::findOrFail($estimate->customer_id);
     $vehicle = Vehicle::findOrFail($estimate->vehicle_id);
     return view('jobs.single-job', compact('job', 'estimate', 'estimate_details', 'department', 's_advisor_list', 'customer', 'vehicle', 'sec_incharge_list'));
 }