/**
  * setMetadata for common pages
  */
 private function setMetadata($prefix = '')
 {
     // metadata
     $site_title = Config::findByKey('site_title')->first()->value;
     if ($prefix != '') {
         $site_title = $prefix . ' - ' . $site_title;
     }
     $meta_description = Config::findByKey('meta_description')->first()->value;
     $meta_keywords = Config::findByKey('meta_keywords')->first()->value;
     SEOMeta::setTitle($site_title);
     SEOMeta::setDescription($meta_description);
     SEOMeta::addKeyword([$meta_keywords]);
     OpenGraph::setTitle($site_title);
     OpenGraph::setDescription($meta_description);
     OpenGraph::setUrl(url());
     OpenGraph::addProperty('type', 'website');
     OpenGraph::addProperty('site_name', 'Kết Nối Mới');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_1.jpg');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_2.jpg');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_3.jpg');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_4.jpg');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_5.jpg');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_6.jpg');
     OpenGraph::addImage(url() . '/frontend/images/fb_share_7.jpg');
     // end metadata
 }
    public function getJSONLD()
    {
        return '{
			"@context": "http://schema.org",
			"@type": "NewsArticle",
			"mainEntityOfPage":{
				"@type":"WebPage",
				"@id":"' . $this->getLink($this->categories()->first()->key) . '"
			},
			"headline": "' . $this->name . '",
			"image": {
				"@type": "ImageObject",
				"url": "' . url() . Image::url($this->getFirstAttachment(), 748, 388, array('crop')) . '",
				"height": "748",
				"width": "388"
			},
			"datePublished": "' . $this->created_at->toW3CString() . '",
			"dateModified": "' . $this->updated_at->toW3CString() . '",
			"author": {
				"@type": "Person",
				"name": "' . $this->created_by . '"
			},
			"publisher": {
				"@type": "Organization",
				"name": "' . Config::findByKey('site_name')->first()->value . '",
				"logo": {
					"@type": "ImageObject",
					"url": "' . url() . '/frontend/images/logo.png",
					"width": "90",
					"height": "21"
    			}
			},
			"description": "' . $this->summary . '"
		}';
    }
 private function setMetadataByCategory($category)
 {
     // metadata
     if ($category != null) {
         // metadata
         $site_title = $category->name . ' - ' . Config::findByKey('site_title')->first()->value;
         SEOMeta::setTitle($site_title);
         SEOMeta::setDescription($category->meta_description);
         SEOMeta::addKeyword([$category->meta_keywords]);
         SEOMeta::addMeta('category:published_time', $category->created_at->toW3CString(), 'property');
         SEOMeta::setTitle($category->name . ' - ' . Config::findByKey('site_title')->first()->value);
         SEOMeta::addMeta('category:section', $category->name, 'property');
         OpenGraph::setTitle($site_title);
         OpenGraph::setDescription($category->meta_description);
         //OpenGraph::setUrl(route('category', ['categorykey' => $categorykey]));
         OpenGraph::addProperty('type', 'category');
         OpenGraph::addProperty('locale', app()->getLocale());
         OpenGraph::addProperty('locale:alternate', ['vi-vn', 'en-us']);
         OpenGraph::addImage($category->getFirstAttachment());
         OpenGraph::addImage($category->attachments->lists('path'));
         OpenGraph::addImage(['url' => Image::url($category->getFirstAttachment(), 300, 300, array('crop')), 'size' => 300]);
         // end metadata
     }
 }
 /**
  * setMetadata for common pages
  */
 private function setMetadata($prefix = '')
 {
     // metadata
     $site_title = Config::findByKey('site_title')->first()->value;
     if ($prefix != '') {
         $site_title = $prefix . ' - ' . $site_title;
     }
     $meta_description = Config::findByKey('meta_description')->first()->value;
     $meta_keywords = Config::findByKey('meta_keywords')->first()->value;
     SEOMeta::setTitle($site_title);
     SEOMeta::setDescription($meta_description);
     SEOMeta::addKeyword([$meta_keywords]);
     OpenGraph::setTitle($site_title);
     OpenGraph::setDescription($meta_description);
     OpenGraph::setUrl(route('homepage'));
     OpenGraph::addProperty('type', 'articles');
     // end metadata
 }
 public function product($districtkey, $productkey)
 {
     $product = Product::where('key', $productkey)->first();
     if ($product != null) {
         $other_products = Product::where('active', 1)->orderBy('priority')->take(5)->get();
         // metadata
         $site_title = $product->name . ' - ' . Config::findByKey('site_title')->first()->value;
         SEOMeta::setTitle($site_title);
         SEOMeta::setDescription($product->meta_description);
         SEOMeta::addKeyword([$product->meta_keywords]);
         SEOMeta::addMeta('product:published_time', $product->created_at->toW3CString(), 'property');
         if (isset($product->product_type->name)) {
             SEOMeta::addMeta('product:section', $product->product_type->name, 'property');
         }
         OpenGraph::setTitle($site_title);
         OpenGraph::setDescription($product->meta_description);
         OpenGraph::setUrl($productgetLink());
         OpenGraph::addProperty('type', 'product');
         OpenGraph::addProperty('locale', app()->getLocale());
         OpenGraph::addProperty('locale:alternate', ['vi-vn', 'en-us']);
         OpenGraph::addImage($product->getThumnail());
         OpenGraph::addImage($product->attachments->lists('path'));
         OpenGraph::addImage(['url' => Image::url($product->getThumnail(), 300, 300, array('crop')), 'size' => 300]);
         // end metadata
         return view('frontend.sites.product', compact('product'));
     } else {
         return view('errors.404');
     }
 }
    /**
     * ARTICLE_DETAIL
     */
    public function article_detail($article_id, $article_key)
    {
        $article = Article::findOrFail($article_id);
        if ($article != null) {
            // metadata
            $site_title = $article->name . ' - ' . Config::findByKey('site_title')->first()->value;
            SEOMeta::setTitle($site_title);
            SEOMeta::setDescription($article->meta_description);
            SEOMeta::addKeyword([$article->meta_keywords]);
            SEOMeta::addMeta('article:published_time', $article->created_at->toW3CString(), 'property');
            if (isset($article->article_category->name)) {
                SEOMeta::addMeta('article:section', $article->article_category->name, 'property');
            }
            OpenGraph::setTitle($site_title);
            OpenGraph::setDescription($article->meta_description);
            OpenGraph::setUrl($article->getLink());
            OpenGraph::addProperty('type', 'article');
            OpenGraph::addProperty('locale', app()->getLocale());
            OpenGraph::addProperty('locale:alternate', ['vi-vn', 'en-us']);
            OpenGraph::addImage($article->getThumnail());
            OpenGraph::addImage($article->attachments->lists('path'));
            OpenGraph::addImage(['url' => Image::url($article->getThumnail(), 300, 300, array('crop')), 'size' => 300]);
            // end metadata
            $attachments = $article->attachments()->take(5)->get();
            $article_category = $article->categories()->first();
            $article_categorys = isset($article_category) ? ArticleCategory::where('id', '<>', $article_category->id)->where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get() : ArticleCategory::where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get();
            $link = $article->getLink();
            $categoryLink = isset($article_category) ? '<li class="active"><a href="' . $article_category->getLink() . '">' . $article_category->name . '</a></li> ' : '';
            $breadcrumb = '<ul class="breadcrumb pull-left padl0"> 
			<li class="active"><a href="' . route('homepage') . '">Trang chủ</a></li> 
			<li class="active"><a href="' . route('articles') . '">Tin tức</a></li> 
			' . $categoryLink . '
			<li class=""><a href="' . $link . '">' . $article->name . '</a></li>
			</ul>';
            return view('frontend.sites1.article_detail', ['article' => $article, 'attachments' => $attachments, 'article_category' => $article_category, 'article_categorys' => $article_categorys, 'search_type' => 'article_detail', 'link' => $link, 'breadcrumb' => $breadcrumb]);
        } else {
            return view('frontend.sites1.article_detail');
        }
    }
 public function article__($categorykey, $articlekey)
 {
     $article = Article::where('key', $articlekey)->first();
     if ($article != null) {
         // metadata
         $site_title = $article->name . ' - ' . Config::findByKey('site_title')->first()->value;
         SEOMeta::setTitle($site_title);
         SEOMeta::setDescription($article->meta_description);
         SEOMeta::addKeyword([$article->meta_keywords]);
         SEOMeta::addMeta('article:published_time', $article->created_at->toW3CString(), 'property');
         if (isset($article->categories->first()->name)) {
             SEOMeta::addMeta('article:section', $article->categories->first()->name, 'property');
         }
         OpenGraph::setTitle($site_title);
         OpenGraph::setDescription($article->meta_description);
         OpenGraph::setUrl(route('article', ['categorykey' => $categorykey, 'articlekey' => $articlekey]));
         OpenGraph::addProperty('type', 'article');
         OpenGraph::addProperty('locale', app()->getLocale());
         OpenGraph::addProperty('locale:alternate', ['vi-vn', 'en-us']);
         OpenGraph::addImage($article->getFirstAttachment());
         OpenGraph::addImage($article->attachments->lists('path'));
         OpenGraph::addImage(['url' => Image::url($article->getFirstAttachment(), 300, 300, array('crop')), 'size' => 300]);
         // end metadata
         return view('frontend.sites.article', compact('article'));
     } else {
         return view('errors.404');
     }
 }
 /**
  * setMetadata for common pages
  */
 private function setMetadata($prefix = '', $route = 'homepage')
 {
     // metadata
     $site_name = Config::findByKey('site_name')->first()->value;
     $site_title = Config::findByKey('site_title')->first()->value;
     if ($prefix != '') {
         $site_title = $prefix . ' - ' . $site_title;
     }
     $meta_description = Config::findByKey('meta_description')->first()->value;
     $meta_keywords = Config::findByKey('meta_keywords')->first()->value;
     SEOMeta::setTitle($site_title);
     SEOMeta::setDescription($meta_description);
     SEOMeta::setKeywords([$meta_keywords]);
     SEOMeta::addMeta('copyright', $site_name);
     SEOMeta::addMeta('author', $site_name);
     SEOMeta::addMeta('robots', 'all');
     SEOMeta::addMeta('revisit-after', '1 days');
     SEOMeta::addAlternateLanguage('vi-vn', route($route));
     SEOMeta::addAlternateLanguage('en-us', route($route));
     OpenGraph::setTitle($site_title);
     OpenGraph::setDescription($meta_description);
     OpenGraph::setUrl(route($route));
     OpenGraph::setSiteName($site_name);
     OpenGraph::addProperty('type', 'website');
     $social_banner = NavigationCategory::findByKey('banner-social')->first()->navigations()->where('is_publish', 1)->orderBy('priority')->take(5)->get();
     foreach ($social_banner as $key => $banner) {
         OpenGraph::addImage(url() . $banner->getFirstAttachment());
     }
     OpenGraph::addProperty('image:width', 1200);
     OpenGraph::addProperty('image:height', 630);
     // end metadata
 }