54 lines
1.0 KiB
PHP
54 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
use Hyperf\Database\Model\Relations\BelongsTo;
|
|
use Hyperf\Database\Model\Relations\HasMany;
|
|
use Hyperf\DbConnection\Model\Model;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property int|null $group_id
|
|
* @property string $method
|
|
* @property string $path
|
|
* @property string|null $name
|
|
* @property string|null $label
|
|
*/
|
|
class Route extends Model
|
|
{
|
|
protected ?string $table = 'routes';
|
|
|
|
public bool $timestamps = false;
|
|
|
|
protected array $fillable = [
|
|
'group_id',
|
|
'method',
|
|
'path',
|
|
'name',
|
|
'label',
|
|
];
|
|
|
|
protected array $casts = [
|
|
'id' => 'integer',
|
|
'group_id' => 'integer',
|
|
];
|
|
|
|
/**
|
|
* 所属分组
|
|
*/
|
|
public function group(): BelongsTo
|
|
{
|
|
return $this->belongsTo(RouteGroup::class, 'group_id');
|
|
}
|
|
|
|
/**
|
|
* 路由的角色覆盖规则
|
|
*/
|
|
public function overrides(): HasMany
|
|
{
|
|
return $this->hasMany(RoleRouteOverride::class, 'route_id');
|
|
}
|
|
}
|