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