form = ConditionForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('assetise.asset.modules'), 'asset', guard_url('asset')); } /** * Display a list of condition. * * @return Response */ public function index(ConditionResourceRequest $request) { $request = $request->all(); $page = ConditionActions::run('paginate', $request); $data = new ConditionsCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('asset::condition.names')) ->view('asset::condition.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display condition. * * @param Request $request * @param Model $condition * * @return Response */ public function show(ConditionResourceRequest $request, Condition $model) { $form = $this->form; $modules = $this->modules; $data = new ConditionResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('asset::condition.name')) ->data(compact('data', 'form', 'modules')) ->view('asset::condition.show') ->output(); } /** * Show the form for creating a new condition. * * @param Request $request * * @return Response */ public function create(ConditionResourceRequest $request, Condition $model) { $form = $this->form; $modules = $this->modules; $data = new ConditionResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('asset::condition.name')) ->view('asset::condition.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new condition. * * @param Request $request * * @return Response */ public function store(ConditionResourceRequest $request, Condition $model) { try { $request = $request->all(); $model = ConditionAction::run('store', $model, $request); $data = new ConditionResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('asset::condition.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('asset/condition/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/asset/condition')) ->redirect(); } } /** * Show condition for editing. * * @param Request $request * @param Model $condition * * @return Response */ public function edit(ConditionResourceRequest $request, Condition $model) { $form = $this->form; $modules = $this->modules; $data = new ConditionResource($model); // return view('asset::condition.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('asset::condition.name')) ->view('asset::condition.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the condition. * * @param Request $request * @param Model $condition * * @return Response */ public function update(ConditionResourceRequest $request, Condition $model) { try { $request = $request->all(); $model = ConditionAction::run('update', $model, $request); $data = new ConditionResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('asset::condition.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('asset/condition/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('asset/condition/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the condition. * * @param Model $condition * * @return Response */ public function destroy(ConditionResourceRequest $request, Condition $model) { try { $request = $request->all(); $model = ConditionAction::run('destroy', $model, $request); $data = new ConditionResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('asset::condition.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('asset/condition/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('asset/condition/' . $model->getRouteKey())) ->redirect(); } } }