diff --git a/app/Models/Category.php b/app/Models/Category.php index ac35af1..033d877 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -40,14 +40,17 @@ class Category extends Model } /** - * 关联的数据 - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany|\Illuminate\Database\Eloquent\Relations\HasMany|\Illuminate\Database\Eloquent\Relations\HasOne|null [type] [description] + * Notes: description + * @Author: 玄尘 + * @Date : 2021/10/14 11:53 + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo|\Illuminate\Database\Eloquent\Relations\HasMany|null */ public function relations() { switch ($this->type) { case self::TYPE_SHOW: - return $this->hasOne(Article::class)->where('id', $this->article_id); + return $this->belongsTo(Article::class); + // return $this->hasOne(Article::class); break; case self::TYPE_ARTICLE: // return $this->belongsToMany(Article::class); diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php index 1699efe..47c85d7 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -385,17 +385,21 @@
@if(getCateChild(73)) @foreach(getCateChild(73) as $cate) -
-
-
{{ $cate->title }}
-
+
url && $cate->type=='link') + data-href="{{ $cate->url }}" + @endif + /> +
+
{{ $cate->title }}
- @endforeach - @endif
+ @endforeach + @endif
+ @endsection