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