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