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