repository = $adjustments; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Bixo\Salary\Repositories\Criteria\AdjustmentsResourceCriteria::class); } /** * Display a list of adjustments. * * @return Response */ public function index(AdjustmentsRequest $request) { return $this->repository ->setPresenter(\Bixo\Salary\Repositories\Presenter\AdjustmentsPresenter::class) ->paginate(); } /** * Display adjustments. * * @param Request $request * @param Model $adjustments * * @return Response */ public function show(AdjustmentsRequest $request, Adjustments $adjustments) { return $adjustments->setPresenter(\Bixo\Salary\Repositories\Presenter\AdjustmentsListPresenter::class); ; } /** * Create new adjustments. * * @param Request $request * * @return Response */ public function store(AdjustmentsRequest $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('salary::adjustments.name')]); $code = 204; $status = 'success'; $url = guard_url('salary/adjustments/' . $adjustments->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('salary/adjustments'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the adjustments. * * @param Request $request * @param Model $adjustments * * @return Response */ public function update(AdjustmentsRequest $request, Adjustments $adjustments) { try { $data = $request->all(); $adjustments->update($data); $message = trans('messages.success.updated', ['Module' => trans('salary::adjustments.name')]); $code = 204; $status = 'success'; $url = guard_url('salary/adjustments/' . $adjustments->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('salary/adjustments/' . $adjustments->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the adjustments. * * @param Model $adjustments * * @return Response */ public function destroy(AdjustmentsRequest $request, Adjustments $adjustments) { try { $adjustments->delete(); $message = trans('messages.success.deleted', ['Module' => trans('salary::adjustments.name')]); $code = 202; $status = 'success'; $url = guard_url('salary/adjustments/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('salary/adjustments/' . $adjustments->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); } }