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