/**
  * Страница редактирования группы категорий.
  *
  * @param $id
  * @return \Illuminate\View\View
  */
 public function getEdit($id)
 {
     // Ищем фирму по короткому названию
     $data['company'] = Company::whereShortTitle($this->companyName)->first();
     // Ищем группу
     $data['group_category'] = $this->findGroupCategory($id);
     return view('admin.companies.catalog.groups_categories.edit', $data);
 }
 /**
  * Отображает индексную страницу модуля
  *
  * @return \Illuminate\View\View
  */
 public function getShow($shortTitle)
 {
     // Ищем кфирму по короткому названию
     $data['company'] = Company::whereShortTitle($shortTitle)->first();
     if (empty($data['company'])) {
         abort(404);
     }
     return view('marketing.companies.descriptions.show', $data);
 }
 /**
  * Отображает интдексную страницу.
  *
  * @return Response
  */
 public function getIndex()
 {
     // Ищем фирму по короткому названию
     $data['company'] = Company::whereShortTitle($this->companyName)->first();
     // Статья
     Model::unguard();
     $data['catalog_description'] = Article::firstOrCreate(['type' => $this->companyName . '_catalog_description']);
     Model::reguard();
     return view('admin.companies.catalog.settings.index', $data);
 }
 /**
  * Дейстиве для отображения страницы галереи компании.
  *
  * @param $company
  * @return \Illuminate\View\View
  */
 public function getShow($company)
 {
     // Статья
     Model::unguard();
     $data['article'] = Article::firstOrCreate(['type' => 'gallery_' . $company . '_description']);
     Model::reguard();
     // Фотографии
     $data['photos'] = Gallery::whereHas('company', function ($query) use($company) {
         $query->where('short_title', '=', $company);
     })->orderBy('created_at', 'DESC')->paginate(9);
     // Компания
     $data['company'] = Company::whereShortTitle($company)->first(['title']);
     // Отображаем
     return view('marketing.galleries.show', $data);
 }
 /**
  * Отображает индексную страницу модуля.
  *
  * @return \Illuminate\Http\Response
  */
 public function getIndex(Request $request)
 {
     // Проверка правильная ли компания (функциональность должна работать для двух компаний - СФС и Праймер)
     $shortTitle = $request->segment(2);
     if (!in_array($shortTitle, ['sfs', 'primer'])) {
         abort(404);
     }
     // Данные компании
     $data['company'] = Company::whereShortTitle($shortTitle)->first();
     // Статья
     Model::unguard();
     $data['videos_description'] = Article::firstOrCreate(['type' => $shortTitle . '_videos_description']);
     Model::reguard();
     // Видео
     $data['videos'] = $data['company']->videos()->orderBy('created_at', 'DESC')->paginate(4);
     return view('marketing.videos.index', $data);
 }
 /**
  * Отображает индексную страницу модуля
  *
  * @return \Illuminate\View\View
  */
 public function getIndex()
 {
     // Ищем фирму по короткому названию
     $data['company'] = Company::whereShortTitle($this->companyName)->first();
     if (empty($data['company'])) {
         abort(404);
     }
     // Статья с описанием прайс-листа
     $data['article'] = Article::firstOrCreate(['type' => 'price_list_description']);
     // Последнее обновление прайса
     $last_update = Memory::get('price.primer.last_update');
     $data['last_update'] = 'Никогда';
     if ($last_update) {
         $data['file_name'] = Memory::get('price.primer.file_name');
         $data['last_update'] = date('d.m.Y в H:i:s', strtotime($last_update));
     }
     return view('admin.companies.price_list.index', $data);
 }
 /**
  * @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 StoreVideosRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postEdit(StoreVideosRequest $request)
 {
     $id = $request->segment(6);
     $video = Video::find($id);
     if (empty($video)) {
         abort(404);
     }
     // Меняем данные и сохраняем
     $video->youtube_id = trim($request->youtube_id);
     $video->company_id = Company::whereShortTitle($request->segment(3))->first()->id;
     $video->save();
     return redirect()->action('Admin\\VideosController@getEdit', ['company' => $request->segment(3), 'id' => $id])->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', 'Сертификат успешно сохранен.');
 }
 public function __construct()
 {
     View::share('company', Company::whereShortTitle($this->shortTitle)->first());
 }
 /**
  * Страница редактирования группы категорий.
  *
  * @param $id
  * @return \Illuminate\View\View
  */
 public function getEdit($id)
 {
     // Ищем фирму по короткому названию
     $data['company'] = Company::whereShortTitle($this->companyName)->first();
     // Ищем категорию
     $data['category'] = $this->findCategory($id);
     // Группы категорий
     $data['groups_categories'] = GroupsCategory::whereCompanyId($data['company']->id)->orderBy('title')->get();
     return view('admin.companies.catalog.categories.edit', $data);
 }