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) { return $this->repository ->setPresenter(\Bixo\Employee\Repositories\Presenter\SalaryHistoryPresenter::class) ->paginate(); } /** * Display salary_history. * * @param Request $request * @param Model $salary_history * * @return Response */ public function show(SalaryHistoryRequest $request, SalaryHistory $salary_history) { return $salary_history->setPresenter(\Bixo\Employee\Repositories\Presenter\SalaryHistoryListPresenter::class); ; } /** * Create new salary_history. * * @param Request $request * * @return Response */ public function store(SalaryHistoryRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('employee::salary_history.name')]); $code = 204; $status = 'success'; $url = guard_url('employee/salary_history/' . $salary_history->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('employee/salary_history'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the salary_history. * * @param Request $request * @param Model $salary_history * * @return Response */ public function update(SalaryHistoryRequest $request, SalaryHistory $salary_history) { try { $data = $request->all(); $salary_history->update($data); $message = trans('messages.success.updated', ['Module' => trans('employee::salary_history.name')]); $code = 204; $status = 'success'; $url = guard_url('employee/salary_history/' . $salary_history->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('employee/salary_history/' . $salary_history->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the salary_history. * * @param Model $salary_history * * @return Response */ public function destroy(SalaryHistoryRequest $request, SalaryHistory $salary_history) { try { $salary_history->delete(); $message = trans('messages.success.deleted', ['Module' => trans('employee::salary_history.name')]); $code = 202; $status = 'success'; $url = guard_url('employee/salary_history/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('employee/salary_history/' . $salary_history->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }