/**
  * Отображает индексную страницу модуля
  *
  * @return \Illuminate\View\View
  */
 public function getIndex()
 {
     // Ищем данные прайс-листа
     $data['article'] = Article::firstOrCreate(['type' => 'price_list_description']);
     $data['file_name'] = Memory::get('price.primer.file_name');
     return view('marketing.companies.price_list.index', $data);
 }
 /**
  * Действие для отображения страницы настроек модуля.
  *
  * @return \Illuminate\View\View
  */
 public function getSettings(Request $request)
 {
     // Статья с описанием сертификатов
     Model::unguard();
     $data['videos_description'] = Article::firstOrCreate(['type' => $request->segment(3) . '_videos_description']);
     Model::reguard();
     return view('admin.videos.settings', $data);
 }
 /**
  * Действие для отображения страницы настроек модуля.
  *
  * @return \Illuminate\View\View
  */
 public function getSettings()
 {
     // Статья с описанием сертификатов
     Model::unguard();
     $data['certificates_description'] = Article::firstOrCreate(['type' => 'certificates_description']);
     Model::reguard();
     return view('admin.certificates.settings', $data);
 }
Example #4
0
 /**
  * Отображает список новостей.
  *
  * @return \Illuminate\Http\Response
  */
 public function getIndex()
 {
     // Статья с описанием новостей
     Model::unguard();
     $data['news_description'] = Article::firstOrCreate(['type' => 'news_description']);
     Model::reguard();
     $data['news'] = News::orderBy('created_at', 'DESC')->paginate(4);
     return view('marketing.news.index', $data);
 }
 /**
  * Отображение страницы "Контакты"
  *
  * @return Response
  */
 public function getIndex()
 {
     // Контактные данные
     $data['contacts_form_text'] = Article::firstOrCreate(['type' => 'contacts_form_text']);
     $data['contacts_contacts'] = Article::firstOrCreate(['type' => 'contacts_contacts']);
     $data['contacts_working_time'] = Article::firstOrCreate(['type' => 'contacts_working_time']);
     $data['contacts_why_us'] = Article::firstOrCreate(['type' => 'contacts_why_us']);
     return view('marketing.contacts.index', $data);
 }
 /**
  * Действие для отображения страницы настроек модуля.
  *
  * @return \Illuminate\View\View
  */
 public function getSettings()
 {
     // Статья с описанием сертификатов
     Model::unguard();
     $data['article'] = Article::firstOrCreate(['type' => 'gallery_' . $this->companyName . '_description']);
     Model::reguard();
     $data['companyName'] = Company::whereShortTitle($this->companyName)->first(['title'])->title;
     $data['companyNameShort'] = $this->companyName;
     return view('admin.galleries.settings', $data);
 }
 /**
  * Действие для отображения индексной страницы модуля.
  *
  * @return \Illuminate\Http\Response
  */
 public function getIndex()
 {
     // Контактные данные
     Model::unguard();
     $data['main_article'] = Article::firstOrCreate(['type' => 'main_article']);
     $data['footer_about'] = Article::firstOrCreate(['type' => 'footer_about']);
     $data['footer_contacts'] = Article::firstOrCreate(['type' => 'footer_contacts']);
     Model::reguard();
     return view('admin.settings.index', $data);
 }
 /**
  * Отображает индексную страницу модуля.
  *
  * @return \Illuminate\Http\Response
  */
 public function getIndex()
 {
     // Статья
     Model::unguard();
     $data['certificates_description'] = Article::firstOrCreate(['type' => 'certificates_description']);
     Model::reguard();
     // Сертификаты
     $data['certificates'] = Certificate::orderBy('created_at', 'DESC')->paginate(6);
     return view('marketing.certificates.index', $data);
 }
 /**
  * Индексная страница каталога
  *
  * @return View
  */
 public function getIndex()
 {
     // Статья
     Model::unguard();
     $data['catalog_description'] = Article::firstOrCreate(['type' => $this->shortTitle . '_catalog_description']);
     Model::reguard();
     // Получаем группы категорий для фирмы вместе с подкатегориями
     $data['group_categories'] = $this->getCategories();
     // Отображаем
     return view('marketing.companies.catalog.' . $this->shortTitle . '.index', $data);
 }
 /**
  * Обработчик запроса на редактирование настроек
  *
  * @return Response
  */
 public function postIndex(Requests\StoreCatalogSettingsRequest $request)
 {
     $settings = Article::firstOrCreate(['type' => $this->companyName . '_catalog_description']);
     // Меняем данные и сохраняем
     $settings->full_text = trim($request->get('full_text'));
     $settings->page_title = trim($request->get('page_title'));
     $settings->page_keywords = trim($request->get('page_keywords'));
     $settings->page_description = trim($request->get('page_description'));
     $settings->page_h1 = trim($request->get('page_h1'));
     $settings->save();
     return redirect()->back()->with('success', 'Настройки успешно сохранены.');
 }
 public function getIndex()
 {
     // Статья
     Model::unguard();
     $data['catalog_description'] = Article::firstOrCreate(['type' => 'primer_catalog_description']);
     Model::reguard();
     // Получаем группы категорий для фирмы вместе с подкатегориями
     $data['group_categories'] = $this->getCategories();
     // Продукты
     $data['products'] = ProductPrimer::whereEnabled(TRUE)->orderBy('created_at')->paginate(9);
     // Отображаем
     return view('marketing.companies.catalog.primer.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);
 }
Example #14
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->except('_token');
     $article = Article::firstOrCreate(['title' => $data['title'], 'category_id' => $data['category_id'], 'user_id' => \Auth::user()->id]);
     $article->content = $data['content'];
     $article->status = (int) $data['status'];
     $article->save();
     $path = 'images/articles/article' . $article->id . '/';
     $destinationPath = public_path($path);
     if ($request->hasFile('image_url')) {
         $name = $request->file('image_url')->getClientOriginalName();
         $request->file('image_url')->move($destinationPath, $name);
         $article->image_url = $path . $name;
         $article->save();
     }
     return redirect()->route('admin.articles.show', $article->id)->with(['message' => 'success!']);
 }
 /**
  * Отображает индексную страницу модуля
  *
  * @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);
 }
 public function store(Request $request)
 {
     $rules = ['title' => 'required|max:100', 'summernote' => 'required', 'tags' => 'required'];
     //Use validator to check the data that user input
     $validator = Validator::make($request->input(), $rules);
     if ($validator->passes()) {
         $article = Article::firstOrCreate(['title' => $request->input('title'), 'article_uid' => Auth::id(), 'content' => $request->input('summernote'), 'comment_permition' => $request->has('comment_permition') ? 0 : 1, 'is_public' => $request->has('is_public') ? 0 : 1, 'reproduct_permition' => $request->has('reproduct_permition') ? 0 : 1, 'type' => $request->has('article-type') ? $request->input('article-type') : 0]);
         //If user selects the exist tag, we just add the count of tag;
         //else we add a new tag into database.
         $tag = Tag::where('tag_uid', Auth::id())->where('name', $request->input('tags'))->first();
         if (isset($tag)) {
             $tag->increment('count');
         } else {
             $tag = Tag::firstOrCreate(['tag_uid' => Auth::id(), 'name' => $request->input('tags'), 'count' => 1]);
         }
         $article->tags()->attach($tag->id);
         /*if ($request->hasFile('image')) {
               if ($request->file('image')->isValid()) {
                   $destPath = '/home/vagrant/Code/Project/resources/uploads/'.Auth::id(); // upload path
                   $extension = $request->file('image')->getClientOriginalExtension();
                   $fileName = date('Y_m_d_H_i_s').'_'.rand(1,9999).'.'.$extension; // renameing image
                   $request->file('image')->move($destPath, $fileName);
                   $attachment = Attachment::firstOrCreate([
                       'title' => $fileName, 
                       'article_id' => $article->id,
                       'size' => $request->file('image')->getClientSize(),
                       'extension' => $extension,
                       'save_path' => $destPath,
                   ]);
               }
           }*/
         return redirect()->action('SelfMainpageController@index');
     } else {
         dd($validator->errors());
         return redirect('/create')->withInput()->withErrors($validator);
     }
 }
Example #17
0
use App\News;
use App\Article;
use App\Slider;
// Виджет слайдера
Widget::register('slider', function () {
    // Получение данных
    $data['slider'] = Slider::orderBy('order', 'ASC')->get();
    // Отображение
    return view('marketing.widgets.slider', $data);
});
// Виджет новостей в футере
Widget::register('footer_latest_news', function () {
    // Получаем новости, которые должны быть на главной
    $data['news'] = News::whereIsOnMain(TRUE)->orderBy('created_at', 'DESC')->limit(3)->get();
    // Отображаем
    return view('marketing.widgets.footer_latest_news', $data);
});
// Виджет "О Компании" в футере
Widget::register('footer_about', function () {
    // Получаем данные
    $data['text'] = Article::firstOrCreate(['type' => 'footer_about'])->full_text;
    // Отображаем
    return view('marketing.widgets.footer_about', $data);
});
// Виджет "Зв'яжіться з нами" в футере
Widget::register('footer_contacts', function () {
    // Получаем данные
    $data['text'] = Article::firstOrCreate(['type' => 'footer_contacts'])->full_text;
    // Отображаем
    return view('marketing.widgets.footer_contacts', $data);
});
Example #18
0
 /**
  * 把从微信服务器获取到的文章信息, 保存到DB
  * 计划做成定时任务, 不需要返回数据
  *
  * @method writeDataToDB
  */
 public function writeDataToDB()
 {
     $total_count = self::getMeterialCount();
     // 取得素材数量
     $offset = json_decode($total_count)->news_count - 1;
     // 便于取得最后2篇文章
     $type = 'news';
     $offset = 50;
     $count = 10;
     // 取得access_token
     $ACCESS_TOKEN = self::getToken();
     /**
      * 拼接url
      * @var string
      */
     $url = "https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token={$ACCESS_TOKEN}";
     /**
      * 提交给服务器的json格式的字符串
      * @var string
      */
     $data = '{"type":"' . $type . '", "offset":"' . $offset . '", "count":"' . $count . '"}';
     // $data = '{"type":"$type", "offset":"50", "count":"10"}';
     /**
      * 提交服务器使用的方法
      * @var string
      */
     $method = 'POST';
     /**
      * 获取服务器返回的数据
      * @var json
      */
     $result = self::http($url, $data, $method);
     /**
      * 将 $result 转化成Array
      */
     $result = json_decode($result, true);
     dd($result);
     $result_arr = $result['item'];
     /**
      * 遍历每一篇文章
      */
     foreach ($result_arr as $value) {
         $tmp_data['update_time'] = date('Y-m-d H:i:s', $value['update_time']);
         // 素材更新的时间
         $tmp_data['media_id'] = $value['media_id'];
         // 素材更新的时间
         $items = $value['content']['news_item'];
         // news_item的值
         /**
          * 遍历文章的每个部分
          */
         foreach ($items as $item) {
             $tmp_data['title'] = $item['title'];
             // 标题
             $tmp_data['digest'] = $item['digest'];
             // 摘要
             $tmp_data['thumb_media_id'] = $item['thumb_media_id'];
             // 缩略图ID
             $tmp_data['url'] = $item['url'];
             // 文章所在的微信服务器的地址
             $tmp_data['thumb_url'] = $item['thumb_url'];
             // 缩略图的URL
             $lists[] = $tmp_data;
             // 将生成的数据填充到lists数组
         }
     }
     /**
      * 将数据按条插入数据库
      */
     foreach ($lists as $list) {
         Article::firstOrCreate($list);
     }
 }
Example #19
0
 /**
  * Действие для отображения страницы настроек модуля.
  *
  * @return \Illuminate\View\View
  */
 public function getSettings()
 {
     // Статья с описанием новостей
     Model::unguard();
     $data['news_description'] = Article::firstOrCreate(['type' => 'news_description']);
     Model::reguard();
     return view('admin.news.settings', $data);
 }
Example #20
0
 public function pullNewsFromRemote()
 {
     $this->refreshToken();
     $api = config("wechat_api.news.pull") . $this['access_token'];
     $post_data = array("type" => "news", "offset" => 0, "count" => 20);
     $result = httpPost($api, json_encode($post_data));
     $news_list = json_decode($result[1], true);
     foreach ($news_list['item'] as $news) {
         $news_media_id = $news['media_id'];
         foreach ($news['content']['news_item'] as $k => $article) {
             $article['news_media_id'] = $news_media_id;
             $article['order'] = $k;
             $article['mp_id'] = $this['id'];
             //处理外链图片
             $pattern = "/http:\\/\\/mmbiz.qpic.cn/";
             $replacement = "https://mmbiz.qlogo.cn";
             $article['thumb_url'] = preg_replace($pattern, $replacement, $article['thumb_url']);
             $article['content'] = preg_replace($pattern, $replacement, $article['content']);
             $t_article = Article::firstOrCreate(["news_media_id" => $news_media_id, "order" => $k]);
             foreach ($article as $k => $v) {
                 $t_article[$k] = $v;
             }
             $t_article->save();
         }
     }
 }