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