refactor: 修复知识库和操作指引
This commit is contained in:
58
app/Models/GuidePage.php
Normal file
58
app/Models/GuidePage.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use SolutionForest\FilamentTree\Concern\ModelTree;
|
||||
|
||||
class GuidePage extends Model
|
||||
{
|
||||
use ModelTree;
|
||||
|
||||
protected $fillable = [
|
||||
'guide_id',
|
||||
'page_number',
|
||||
'title',
|
||||
'html_url',
|
||||
'sort_order',
|
||||
'parent_id',
|
||||
'options',
|
||||
'branch_option',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'options' => 'array',
|
||||
'parent_id' => 'int',
|
||||
];
|
||||
|
||||
// filament-tree column name mapping
|
||||
public function determineParentColumnName(): string
|
||||
{
|
||||
return 'parent_id';
|
||||
}
|
||||
|
||||
public function determineOrderColumnName(): string
|
||||
{
|
||||
return 'sort_order';
|
||||
}
|
||||
|
||||
public function determineTitleColumnName(): string
|
||||
{
|
||||
return 'title';
|
||||
}
|
||||
|
||||
public function guide()
|
||||
{
|
||||
return $this->belongsTo(Guide::class);
|
||||
}
|
||||
|
||||
public function branchChildren()
|
||||
{
|
||||
return $this->hasMany(self::class, 'parent_id')->orderBy('sort_order');
|
||||
}
|
||||
|
||||
public function parentPage()
|
||||
{
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user