Add (article): ai gen, front views
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $short_name
|
||||
* @property string|null $slug
|
||||
* @property bool $enabled
|
||||
* @property Carbon|null $created_at
|
||||
@@ -39,6 +40,7 @@ class Category extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'short_name',
|
||||
'slug',
|
||||
'enabled',
|
||||
'_lft',
|
||||
@@ -64,4 +66,16 @@ public function saveQuietly(array $options = [])
|
||||
return $this->save($options);
|
||||
});
|
||||
}
|
||||
|
||||
public function posts()
|
||||
{
|
||||
return $this->hasManyThrough(
|
||||
Post::class,
|
||||
PostCategory::class,
|
||||
'category_id', // Foreign key on PostCategory table
|
||||
'id', // Local key on Post table
|
||||
'id', // Local key on Category table
|
||||
'post_id' // Foreign key on PostCategory table
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user