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