- 新增3个migration(9张表): office(6表)/report(1表)/kb(2表) - 新增9个Model + 9个Controller - 新增43条API路由(总计305条) - 新增3个前端API模块 + 10个管理页面 - 迁移运行通过, vite build验证通过
41 lines
851 B
PHP
41 lines
851 B
PHP
<?php
|
|
|
|
namespace App\Models\Kb;
|
|
|
|
use App\Traits\BelongsToStore;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class KbCategory extends Model
|
|
{
|
|
use BelongsToStore;
|
|
|
|
protected $fillable = [
|
|
'store_id', 'parent_id', 'name', 'sort', 'status',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'sort' => 'integer',
|
|
'status' => 'integer',
|
|
];
|
|
}
|
|
|
|
public function children(): HasMany
|
|
{
|
|
return $this->hasMany(self::class, 'parent_id');
|
|
}
|
|
|
|
public function parent(): BelongsTo
|
|
{
|
|
return $this->belongsTo(self::class, 'parent_id');
|
|
}
|
|
|
|
public function articles(): HasMany
|
|
{
|
|
return $this->hasMany(KbArticle::class, 'category_id');
|
|
}
|
|
}
|