public function postChangeLang(Request $request) { if ($request->has('language')) { return FormLang::setCurrentLang($request->get('language')); } else { return Main::message('Wrong parameters!', 'Error', 'error'); } }
public function __construct() { Main::init(); view()->share('locale', FormLang::getCurrentLang()); view()->share('itemName', $this->itemName); view()->share('partition', $this->itemName); view()->share('title', $this->itemName); view()->share('template', $this->template); view()->share('layout', $this->layout); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function postUpdate(Request $request, $id) { $this->validation->mergeRules('alias', ['required', 'regex:/^[a-zа-я\\d-]+$/', 'max:255']); if ($this->validation->fails()) { return $this->validation->errors()->toJson(); } $content = $this->currentModel->find($id); $data = $request->all(); $image = $request->file('image'); $path = public_path() . '/img/content/' . $request->get('structure_id') . '/'; $name = time() . '-' . $image->getClientOriginalName(); if (!\File::exists($path)) { \File::makeDirectory($path, 0775); } $image->move($path, $name); $content->alias = $data['alias']; $content->date_start = $content->date_start = Main::getDateFromPicker($data['date_start']); $content->save(); $langContent = $this->langModel->where('content_id', $id)->where('language_id', FormLang::getCurrentLang())->first(); if ($langContent) { $langContent->name = $data['name']; $langContent->description = $data['description']; $langContent->content = $data['content']; $langContent->save(); } else { $langContent = new ContentLang(); $langContent->content_id = $content->id; $langContent->language_id = FormLang::getCurrentLang(); $langContent->name = $data['name']; $langContent->description = $data['description']; $langContent->content = $data['content']; $langContent->save(); } return Main::redirect('', '302', 'Content was saved', 'Saved', 'success'); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function postUpdate(Request $request, $id) { $this->validation->mergeRules('alias', ['required', 'regex:/^[a-zа-я\\d-]+$/', 'max:255']); if ($this->validation->fails()) { return $this->validation->errors()->toJson(); } $objectStructure = $this->currentModel->find($id); $data = $request->all(); $objectStructure->alias = $data['alias']; $objectStructure->parent_id = $data['parent_id']; $objectStructure->controller = $data['controller']; $objectStructure->save(); $langStructure = $this->langModel->where('structure_id', $id)->where('language_id', FormLang::getCurrentLang())->first(); if ($langStructure) { $langStructure->name = $data['name']; $langStructure->description = $data['description']; $langStructure->save(); } else { $langStructure = new StructureLang(); $langStructure->structure_id = $objectStructure->id; $langStructure->language_id = FormLang::getCurrentLang(); $langStructure->name = $data['name']; $langStructure->description = $data['description']; $langStructure->save(); } return Main::redirect('', '302', 'Structure was saved', 'Saved', 'success'); }