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