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