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