This commit is contained in:
2021-10-14 11:54:38 +08:00
parent ad0f7b25a1
commit 14011f9674
2 changed files with 17 additions and 10 deletions

View File

@@ -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);