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