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