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