Пример #1
0
 /**
  * 获取所有Meta元数据
  *
  * @param  string $type 元模型类型 分类category,标签tag
  * @return Illuminate\Support\Collection
  */
 public function meta($type = 'category')
 {
     if ($type === 'tag') {
         $metas = $this->meta->tag()->get();
     } else {
         $metas = $this->meta->category()->get();
     }
     return $metas;
 }
Пример #2
0
 /**
  * 创建或更新Meta分类
  *
  * @param  YCMS\Models\Meta $meta
  * @param  array $inputs
  * @return YCMS\Models\Meta
  */
 private function saveCategory($meta, $inputs)
 {
     $meta->name = e($inputs['name']);
     $meta->description = e($inputs['description']);
     $meta->type = 'category';
     if (array_key_exists('slug', $inputs)) {
         $meta->slug = e($inputs['slug']);
     }
     $meta->save();
     return $meta;
 }
Пример #3
0
 /**
  * 博客文章
  */
 public function getArticleShow($cslug, $slug)
 {
     //尝试根据分类slug来匹配
     $category = Meta::category()->where('slug', '=', $cslug)->first();
     if ($category) {
         $article = Content::article()->where('category_id', '=', $category->id)->where('slug', '=', $slug)->first();
         if ($article) {
             $title = $article->title;
             $description = Cache::get('website_title', '芽丝博客') . ' - ' . $title . ',本博客由 芽丝内容管理框架(YASCMF) 所驱动的博客,基于Laravel实现的内容管理框架,Github地址: https://github.com/douyasi/yascmf 。';
             return view('front.show', compact('article', 'category', 'title', 'description'));
         } else {
             if (ctype_digit($slug)) {
                 $article = Content::article()->where('category_id', '=', $category->id)->find($slug);
                 is_null($article) && abort(404);
                 $title = $article->title;
                 $description = Cache::get('website_title', '芽丝博客') . ' - ' . $title . ',本博客由 芽丝内容管理框架(YASCMF) 所驱动的博客,基于Laravel实现的内容管理框架,Github地址: https://github.com/douyasi/yascmf 。';
                 return view('front.show', compact('article', 'category', 'title', 'description'));
             } else {
                 abort(404);
             }
         }
     } else {
         //再次尝试移除'cat_'前缀之后来匹配
         $new_cslug = ltrim($cslug, 'cat_');
         if (ctype_digit($new_cslug)) {
             $category = Meta::category()->find($new_cslug);
             is_null($category) && abort(404);
             $article = Content::article()->where('category_id', '=', $new_cslug)->where('slug', '=', $slug)->first();
             if ($article) {
                 $title = $article->title;
                 $description = Cache::get('website_title', '芽丝博客') . ' - ' . $title . ',本博客由 芽丝内容管理框架(YASCMF) 所驱动的博客,基于Laravel实现的内容管理框架,Github地址: https://github.com/douyasi/yascmf 。';
                 return view('front.show', compact('article', 'category', 'title', 'description'));
             } else {
                 if (ctype_digit($slug)) {
                     $article = Content::article()->where('category_id', '=', $category->id)->find($slug);
                     is_null($article) && abort(404);
                     $title = $article->title;
                     $description = Cache::get('website_title', '芽丝博客') . ' - ' . $title . ',本博客由 芽丝内容管理框架(YASCMF) 所驱动的博客,基于Laravel实现的内容管理框架,Github地址: https://github.com/douyasi/yascmf 。';
                     return view('front.show', compact('article', 'category', 'title', 'description'));
                 } else {
                     abort(404);
                 }
             }
         } else {
             abort(404);
         }
     }
 }