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