repository = $ingreso_vehiculo; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Olger\IngVhiculo\Repositories\Criteria\IngresoVehiculoResourceCriteria::class); } /** * Display a list of ingreso_vehiculo. * * @return Response */ public function index(IngresoVehiculoRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Olger\IngVhiculo\Repositories\Presenter\IngresoVehiculoPresenter::class) ->$function(); } $ingreso_vehiculos = $this->repository->paginate(); return $this->response->setMetaTitle(trans('ing_vhiculo::ingreso_vehiculo.names')) ->view('ing_vhiculo::ingreso_vehiculo.index', true) ->data(compact('ingreso_vehiculos', 'view')) ->output(); } /** * Display ingreso_vehiculo. * * @param Request $request * @param Model $ingreso_vehiculo * * @return Response */ public function show(IngresoVehiculoRequest $request, IngresoVehiculo $ingreso_vehiculo) { if ($ingreso_vehiculo->exists) { $view = 'ing_vhiculo::ingreso_vehiculo.show'; } else { $view = 'ing_vhiculo::ingreso_vehiculo.new'; } return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('ing_vhiculo::ingreso_vehiculo.name')) ->data(compact('ingreso_vehiculo')) ->view($view, true) ->output(); } /** * Show the form for creating a new ingreso_vehiculo. * * @param Request $request * * @return Response */ public function create(IngresoVehiculoRequest $request) { $ingreso_vehiculo = $this->repository->newInstance([]); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('ing_vhiculo::ingreso_vehiculo.name')) ->view('ing_vhiculo::ingreso_vehiculo.create', true) ->data(compact('ingreso_vehiculo')) ->output(); } /** * Create new ingreso_vehiculo. * * @param Request $request * * @return Response */ public function store(IngresoVehiculoRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $ingreso_vehiculo = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('ing_vhiculo::ingreso_vehiculo.name')])) ->code(204) ->status('success') ->url(guard_url('ing_vhiculo/ingreso_vehiculo/' . $ingreso_vehiculo->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/ing_vhiculo/ingreso_vehiculo')) ->redirect(); } } /** * Show ingreso_vehiculo for editing. * * @param Request $request * @param Model $ingreso_vehiculo * * @return Response */ public function edit(IngresoVehiculoRequest $request, IngresoVehiculo $ingreso_vehiculo) { return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('ing_vhiculo::ingreso_vehiculo.name')) ->view('ing_vhiculo::ingreso_vehiculo.edit', true) ->data(compact('ingreso_vehiculo')) ->output(); } /** * Update the ingreso_vehiculo. * * @param Request $request * @param Model $ingreso_vehiculo * * @return Response */ public function update(IngresoVehiculoRequest $request, IngresoVehiculo $ingreso_vehiculo) { try { $attributes = $request->all(); $ingreso_vehiculo->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('ing_vhiculo::ingreso_vehiculo.name')])) ->code(204) ->status('success') ->url(guard_url('ing_vhiculo/ingreso_vehiculo/' . $ingreso_vehiculo->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('ing_vhiculo/ingreso_vehiculo/' . $ingreso_vehiculo->getRouteKey())) ->redirect(); } } /** * Remove the ingreso_vehiculo. * * @param Model $ingreso_vehiculo * * @return Response */ public function destroy(IngresoVehiculoRequest $request, IngresoVehiculo $ingreso_vehiculo) { try { $ingreso_vehiculo->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('ing_vhiculo::ingreso_vehiculo.name')])) ->code(202) ->status('success') ->url(guard_url('ing_vhiculo/ingreso_vehiculo/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('ing_vhiculo/ingreso_vehiculo/' . $ingreso_vehiculo->getRouteKey())) ->redirect(); } } /** * Remove multiple ingreso_vehiculo. * * @param Model $ingreso_vehiculo * * @return Response */ public function delete(IngresoVehiculoRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('ing_vhiculo::ingreso_vehiculo.name')])) ->status("success") ->code(202) ->url(guard_url('ing_vhiculo/ingreso_vehiculo')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/ing_vhiculo/ingreso_vehiculo')) ->redirect(); } } /** * Restore deleted ingreso_vehiculos. * * @param Model $ingreso_vehiculo * * @return Response */ public function restore(IngresoVehiculoRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('ing_vhiculo::ingreso_vehiculo.name')])) ->status("success") ->code(202) ->url(guard_url('/ing_vhiculo/ingreso_vehiculo')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/ing_vhiculo/ingreso_vehiculo/')) ->redirect(); } } }