59 lines
1.1 KiB
PHP
59 lines
1.1 KiB
PHP
<?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');
|
|
}
|
|
}
|