Add (article): ai gen, front views

This commit is contained in:
2023-09-24 22:53:40 +08:00
parent 18705bd5e4
commit 322d680961
115 changed files with 9710 additions and 201 deletions

View File

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