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