Files

54 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2026-03-09 14:14:42 +08:00
<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\Database\Model\Relations\BelongsToMany;
use Hyperf\Database\Model\Relations\HasMany;
use Hyperf\DbConnection\Model\Model;
/**
* @property int $id
* @property string $name
* @property string $label
* @property string|null $description
* @property int $sort_order
* @property \Carbon\Carbon $created_at
*/
class RouteGroup extends Model
{
protected ?string $table = 'route_groups';
public bool $timestamps = false;
protected array $fillable = [
'name',
'label',
'description',
'sort_order',
];
protected array $casts = [
'id' => 'integer',
'sort_order' => 'integer',
'created_at' => 'datetime',
];
/**
* 分组下的路由
*/
public function routes(): HasMany
{
return $this->hasMany(Route::class, 'group_id');
}
/**
* 拥有此分组的角色
*/
public function roles(): BelongsToMany
{
return $this->belongsToMany(Role::class, 'role_route_groups', 'group_id', 'role_id');
}
}