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