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