阶段更新
This commit is contained in:
@@ -18,11 +18,13 @@ class Category extends Model
|
||||
public const TYPE_ARTICLE = 'article';
|
||||
public const TYPE_ADVERT = 'advert';
|
||||
public const TYPE_VIDEO = 'video';
|
||||
public const TYPE_LINK = 'link';
|
||||
public const TYPES = [
|
||||
self::TYPE_ARTICLE => '文章列表',
|
||||
self::TYPE_SHOW => '文章详情',
|
||||
self::TYPE_ADVERT => '图片列表',
|
||||
self::TYPE_VIDEO => '视频列表',
|
||||
self::TYPE_LINK => '跳转链接',
|
||||
];
|
||||
|
||||
public $cover_field = 'cover';
|
||||
@@ -48,7 +50,8 @@ class Category extends Model
|
||||
return $this->hasOne(Article::class)->where('id', $this->article_id);
|
||||
break;
|
||||
case self::TYPE_ARTICLE:
|
||||
return $this->belongsToMany(Article::class);
|
||||
// return $this->belongsToMany(Article::class);
|
||||
return $this->hasMany(Article::class);
|
||||
break;
|
||||
case self::TYPE_ADVERT:
|
||||
return $this->hasMany(Advert::class);
|
||||
@@ -85,13 +88,14 @@ class Category extends Model
|
||||
public function getAllChildrenId(): array
|
||||
{
|
||||
$ids = array_keys($this->buildSelectOptions([], $this->id));
|
||||
|
||||
if ($ids) {
|
||||
array_unshift($ids, $this->id);
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
return [];
|
||||
return [$this->id];
|
||||
}
|
||||
|
||||
// public function articles(): BelongsToMany
|
||||
|
||||
Reference in New Issue
Block a user