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