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