repository = $tbl_courier; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Karneaud\LavaliteKarneaudCargo\Repositories\Criteria\TblCourierResourceCriteria::class); } /** * Display a list of tbl_courier. * * @return Response */ public function index(TblCourierRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Karneaud\LavaliteKarneaudCargo\Repositories\Presenter\TblCourierPresenter::class) ->$function(); } $tbl_couriers = $this->repository->paginate(); return $this->response->title(trans('lavalite-karneaud-cargo::tbl_courier.names')) ->view('lavalite-karneaud-cargo::tbl_courier.index', true) ->data(compact('tbl_couriers', 'view')) ->output(); } /** * Display tbl_courier. * * @param Request $request * @param Model $tbl_courier * * @return Response */ public function show(TblCourierRequest $request, TblCourier $tbl_courier) { if ($tbl_courier->exists) { $view = 'lavalite-karneaud-cargo::tbl_courier.show'; } else { $view = 'lavalite-karneaud-cargo::tbl_courier.new'; } return $this->response->title(trans('app.view') . ' ' . trans('lavalite-karneaud-cargo::tbl_courier.name')) ->data(compact('tbl_courier')) ->view($view, true) ->output(); } /** * Show the form for creating a new tbl_courier. * * @param Request $request * * @return Response */ public function create(TblCourierRequest $request) { $tbl_courier = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('lavalite-karneaud-cargo::tbl_courier.name')) ->view('lavalite-karneaud-cargo::tbl_courier.create', true) ->data(compact('tbl_courier')) ->output(); } /** * Create new tbl_courier. * * @param Request $request * * @return Response */ public function store(TblCourierRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $tbl_courier = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('lavalite-karneaud-cargo::tbl_courier.name')])) ->code(204) ->status('success') ->url(guard_url('lavalite-karneaud-cargo/tbl_courier/' . $tbl_courier->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/lavalite-karneaud-cargo/tbl_courier')) ->redirect(); } } /** * Show tbl_courier for editing. * * @param Request $request * @param Model $tbl_courier * * @return Response */ public function edit(TblCourierRequest $request, TblCourier $tbl_courier) { return $this->response->title(trans('app.edit') . ' ' . trans('lavalite-karneaud-cargo::tbl_courier.name')) ->view('lavalite-karneaud-cargo::tbl_courier.edit', true) ->data(compact('tbl_courier')) ->output(); } /** * Update the tbl_courier. * * @param Request $request * @param Model $tbl_courier * * @return Response */ public function update(TblCourierRequest $request, TblCourier $tbl_courier) { try { $attributes = $request->all(); $tbl_courier->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('lavalite-karneaud-cargo::tbl_courier.name')])) ->code(204) ->status('success') ->url(guard_url('lavalite-karneaud-cargo/tbl_courier/' . $tbl_courier->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('lavalite-karneaud-cargo/tbl_courier/' . $tbl_courier->getRouteKey())) ->redirect(); } } /** * Remove the tbl_courier. * * @param Model $tbl_courier * * @return Response */ public function destroy(TblCourierRequest $request, TblCourier $tbl_courier) { try { $tbl_courier->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('lavalite-karneaud-cargo::tbl_courier.name')])) ->code(202) ->status('success') ->url(guard_url('lavalite-karneaud-cargo/tbl_courier/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('lavalite-karneaud-cargo/tbl_courier/' . $tbl_courier->getRouteKey())) ->redirect(); } } /** * Remove multiple tbl_courier. * * @param Model $tbl_courier * * @return Response */ public function delete(TblCourierRequest $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('lavalite-karneaud-cargo::tbl_courier.name')])) ->status("success") ->code(202) ->url(guard_url('lavalite-karneaud-cargo/tbl_courier')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/lavalite-karneaud-cargo/tbl_courier')) ->redirect(); } } /** * Restore deleted tbl_couriers. * * @param Model $tbl_courier * * @return Response */ public function restore(TblCourierRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('lavalite-karneaud-cargo::tbl_courier.name')])) ->status("success") ->code(202) ->url(guard_url('/lavalite-karneaud-cargo/tbl_courier')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/lavalite-karneaud-cargo/tbl_courier/')) ->redirect(); } } }