/**
  * Запрос на создание слайда
  *
  * @param StoreSlidersRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postCreate(StoreSlidersRequest $request, SavesImages $imageSaver)
 {
     // Создаём новый слайдер
     $slider = new Slider();
     $slider->file_main = $imageSaver->save('file_main', 'slider', 2048, 350);
     $slider->file_logo = $imageSaver->save('file_logo', 'slider' . DIRECTORY_SEPARATOR . 'logo', NULL, 135);
     $slider->url = trim($request->get('url'));
     $slider->text_1 = trim($request->get('text_1'));
     $slider->text_2 = trim($request->get('text_2'));
     $slider->css_main = trim($request->get('css_main'));
     $slider->css_1 = trim($request->get('css_1'));
     $slider->css_2 = trim($request->get('css_2'));
     $slider->css_3 = trim($request->get('css_3'));
     // Присваем макс. порядок + 1
     $slider->order = Slider::max('order') + 1;
     $slider->save();
     return redirect()->action('Admin\\SliderController@getEdit', array('id' => $slider->id))->with('success', 'Слайд успешно создан.');
 }
 /**
  * @param StoreCompanyDescriptionsRequest $request
  * @param SavesImages $imageSaver
  * @return \Illuminate\Http\RedirectResponse
  * @throws \App\Services\Exception
  */
 public function postIndex(StoreCompanyDescriptionsRequest $request, SavesImages $imageSaver)
 {
     // Ищем кфирму по короткому названию
     $company = Company::whereShortTitle($this->companyName)->first();
     if (empty($company)) {
         abort(404);
     }
     // Меняем данные
     $company->title = trim($request->title);
     $company->description = trim($request->description);
     if ($request->hasFile('file_main')) {
         $company->file_main = $imageSaver->save('file_main', 'companies', 370, 247, $company->file_main);
     }
     if ($request->hasFile('file_logo')) {
         $company->file_logo = $imageSaver->save('file_logo', 'companies' . DIRECTORY_SEPARATOR . 'top', NULL, 89, $company->file_logo);
     }
     $company->page_title = trim($request->page_title);
     $company->page_keywords = trim($request->page_keywords);
     $company->page_description = trim($request->page_description);
     $company->page_h1 = trim($request->page_h1);
     $company->save();
     return redirect()->back()->with('success', 'Описание успешно сохранено.');
 }
 /**
  * Действие для редктирования продукта.
  *
  * @param Requests\StoreProductsSfsRequest $request
  * @param SavesImages $imageSaver
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postEdit(Requests\StoreProductsSfsRequest $request, SavesImages $imageSaver, $id)
 {
     $product = $this->findProduct($id);
     // Текстовые данные
     $product->title = trim($request->title);
     $product->category_id = $request->category_id;
     $product->enabled = $request->get('enabled', FALSE);
     $product->description_small = trim($request->description_small);
     $product->description_full = trim($request->description_full);
     // PDF
     if ($request->hasFile('file_name')) {
         // Удаляем старый файл
         File::delete(public_path('assets/img/products/sfs/pdf/' . $product->file_name));
         $generator = \Faker\Factory::create();
         $product->file_name = $generator->uuid . '.pdf';
         $request->file('file_name')->move(public_path('assets/img/products/sfs/pdf/'), $product->file_name);
     }
     // Изображение
     if ($request->hasFile('photo')) {
         $product->photo = $imageSaver->save('photo', 'products/sfs', 260, NULL, $product->photo != 'default.jpg' ? $product->photo : NULL);
     }
     // SEO
     $product->page_title = $request->page_title;
     $product->page_keywords = $request->page_keywords;
     $product->page_description = $request->page_description;
     $product->page_h1 = $request->page_h1;
     // Сохраняем
     $product->save();
     // Возвращаем назад с успехом
     return redirect()->back()->with('success', 'Продукт успешно сохранён.');
 }
 /**
  * Действие-обработчик запроса на редактирование фотографии.
  *
  * @param StoreGalleriesRequest $request
  * @param SavesImages $imageSaver
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  * @throws \App\Services\Exception
  */
 public function postEdit(StoreGalleriesRequest $request, SavesImages $imageSaver, $id)
 {
     $photo = Gallery::whereHas('company', function ($q) use($request) {
         $q->where('short_title', '=', $request->company);
     })->find($id);
     if (empty($photo)) {
         abort(404);
     }
     // Меняем данные и сохраняем
     $photo->title = trim($request->title);
     $photo->company_id = Company::whereShortTitle($request->company)->first(['id'])->id;
     if ($request->hasFile('file_name')) {
         $photo->file_name = $imageSaver->save('file_name', 'galleries', 973, NULL, $photo->file_name);
     }
     $photo->save();
     return redirect('admin/galleries/edit/' . $photo->id . '?company=' . $request->company)->with('success', 'Сертификат успешно сохранен.');
 }
 /**
  * Действие-обработчик запроса на изменение данных объекта
  *
  * @param StoreProjectRequest $request
  * @param SavesImages $imageSaver
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  * @throws \App\Services\Exception
  */
 public function postEdit(StoreProjectRequest $request, SavesImages $imageSaver, $id)
 {
     // Получение данных
     $project = Project::find($id);
     if (empty($project)) {
         abort(404);
     }
     // Присвоение новых значений полей объекту
     $project->title = trim($request->get('title'));
     if (trim($request->get('slug')) != '') {
         $project->slug = trim($request->get('slug'));
     } else {
         $project->slug = str_slug($project->title);
     }
     $project->description_short = trim($request->get('description_short'));
     $project->description_full = trim($request->get('description_full'));
     $project->enabled = (int) $request->get('enabled');
     // Новое изображение
     if ($request->hasFile('image')) {
         $project->image = $imageSaver->save('image', 'projects', 140, 140, $project->image);
     }
     // Сохранение
     $project->save();
     // Переадресовывание назад с сообщением об успехе операции
     return redirect()->back()->with('success', 'Объект успешно обновлён.');
 }
 /**
  * Обработчик запроса на создание новости
  *
  * @return Response
  */
 public function postCreate(StoreNewsRequest $request, SavesImages $imageSaver)
 {
     $news = new News();
     $news->title = trim(Input::get('title'));
     $news->full_text = Input::get('full_text');
     $news->preview_text_small = Input::get('preview_text_small');
     $news->preview_text_mid = Input::get('preview_text_mid');
     $news->is_on_main = Input::get('is_on_main', 0);
     $news->thumbnail = $imageSaver->save('thumbnail', 'news', 555, 370);
     // Настройки seo
     $news->page_title = trim($request->get('page_title'));
     $news->page_keywords = trim($request->get('page_keywords'));
     $news->page_description = trim($request->get('page_description'));
     $news->page_h1 = trim($request->get('page_h1'));
     $news->save();
     return redirect()->action('Admin\\NewsController@getEdit', array('id' => $news->id))->with('success', 'Новость успешно сохранена.');
 }
 /**
  * Действие-обработчик запроса на изменение данных объекта
  *
  * @param StorePartnerRequest $request
  * @param SavesImages $imageSaver
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  * @throws \App\Services\Exception
  */
 public function postEdit(StorePartnerRequest $request, SavesImages $imageSaver, $id)
 {
     // Получение данных
     $partner = Partner::find($id);
     if (empty($partner)) {
         abort(404);
     }
     // Присвоение новых значений полей партнёра
     $partner->title = trim($request->get('title'));
     $partner->description = trim($request->get('description'));
     $partner->web_site = trim($request->get('web_site'));
     $partner->category = trim($request->get('category'));
     $partner->enabled = (int) $request->get('enabled');
     // Изображение
     if ($request->hasFile('image')) {
         $partner->image = $imageSaver->save('image', 'partners', 140, 140);
     }
     // Сохранение
     $partner->save();
     // Переадресовывание назад с сообщением об успехе операции
     return redirect()->back()->with('success', 'Партнёр успешно обновлён.');
 }
 /**
  * Действие для редктирования продукта.
  *
  * @param Requests\StoreProductsSikaRequest $request
  * @param SavesImages $imageSaver
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postEdit(Requests\StoreProductsSikaRequest $request, SavesImages $imageSaver, $id)
 {
     $product = $this->findProduct($id);
     // Текстовые данные
     $product->title = trim($request->title);
     $product->description = trim($request->description);
     $product->package = trim($request->package);
     $product->package_list = trim($request->package_list);
     $product->characteristics = trim($request->characteristics);
     $product->using_area = trim($request->using_area);
     $product->category_id = $request->category_id;
     $product->enabled = $request->get('enabled', FALSE);
     // Изображение
     if ($request->hasFile('photo')) {
         $product->photo = $imageSaver->save('photo', 'products/sika', 260, NULL, $product->photo);
     }
     // Техкарта
     if ($request->hasFile('tech_cart_file')) {
         // Удаляем старый файл
         File::delete(public_path('assets/img/products/sika/tech-carts/' . $product->tech_cart_file));
         $generator = \Faker\Factory::create();
         $product->tech_cart_file = $generator->uuid . '.pdf';
         $request->file('tech_cart_file')->move(public_path('assets/img/products/sika/tech-carts/'), $product->tech_cart_file);
     }
     // SEO
     $product->page_title = $request->page_title;
     $product->page_keywords = $request->page_keywords;
     $product->page_description = $request->page_description;
     $product->page_h1 = $request->page_h1;
     // Сохраняем
     $product->save();
     // Возвращаем назад с успехом
     return redirect()->back()->with('success', 'Продукт успешно сохранён.');
 }
 /**
  * Действие-обработчик запроса на редактирование сертификата
  *
  * @param StoreCertificatesRequest $request
  * @param SavesImages $imageSaver
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  * @throws \App\Services\Exception
  */
 public function postEdit(StoreCertificatesRequest $request, SavesImages $imageSaver, $id)
 {
     $certificate = Certificate::find($id);
     if (empty($certificate)) {
         abort(404);
     }
     // Меняем данные и сохраняем
     $certificate->title = trim($request->title);
     if ($request->hasFile('file_name')) {
         $certificate->file_name = $imageSaver->save('file_name', 'certificates', 630, NULL, $certificate->file_name);
     }
     $certificate->save();
     return redirect()->action('Admin\\CertificatesController@getEdit', array('id' => $id))->with('success', 'Сертификат успешно сохранен.');
 }
 /**
  * Действие для редктирования продукта.
  *
  * @param Requests\StoreProductsSikaRequest $request
  * @param SavesImages $imageSaver
  * @param $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postEdit(Requests\StoreProductsSikaRequest $request, SavesImages $imageSaver, $id)
 {
     $product = $this->findProduct($id);
     // Текстовые данные
     $product->title = trim($request->title);
     $product->category_id = $request->category_id;
     $product->package = trim($request->package);
     $product->description_small = trim($request->description_small);
     $product->description_full = trim($request->description_full);
     $product->using = trim($request->using);
     $product->tech_characteristics = trim($request->tech_characteristics);
     $product->exec_works = trim($request->exec_works);
     $product->application = trim($request->application);
     $product->properties_using = trim($request->properties_using);
     $product->phys_chem_properties = trim($request->phys_chem_properties);
     $product->restrictions = trim($request->restrictions);
     $product->safety = trim($request->safety);
     $product->general_characteristics = trim($request->general_characteristics);
     $product->price_1_name = trim($request->price_1_name);
     $product->price_1_val = trim($request->price_1_val);
     $product->price_2_name = trim($request->price_2_name);
     $product->price_2_val = trim($request->price_2_val);
     $product->price_3_name = trim($request->price_3_name);
     $product->price_3_val = trim($request->price_3_val);
     $product->price_4_name = trim($request->price_4_name);
     $product->price_4_val = trim($request->price_4_val);
     $product->enabled = $request->get('enabled', FALSE);
     // Изображение
     if ($request->hasFile('photo')) {
         $product->photo = $imageSaver->save('photo', 'products/primer', 260, NULL, $product->photo);
     }
     // SEO
     $product->page_title = $request->page_title;
     $product->page_keywords = $request->page_keywords;
     $product->page_description = $request->page_description;
     $product->page_h1 = $request->page_h1;
     // Сохраняем
     $product->save();
     // Возвращаем назад с успехом
     return redirect()->back()->with('success', 'Продукт успешно сохранён.');
 }