40 lines
801 B
PHP
40 lines
801 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
use Hyperf\DbConnection\Model\Model;
|
|
|
|
/**
|
|
* @property int $role_id
|
|
* @property int $menu_id
|
|
*/
|
|
class AdminRoleMenu extends Model
|
|
{
|
|
/**
|
|
* The table associated with the model.
|
|
*/
|
|
protected ?string $table = 'admin_role_menu';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected array $fillable = [];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*/
|
|
protected array $casts = ['role_id' => 'integer', 'menu_id' => 'integer'];
|
|
|
|
/**
|
|
* 获取角色菜单列表
|
|
* @param int $roleId
|
|
* @return array
|
|
*/
|
|
public function getMenuByRoleId(int $roleId): array
|
|
{
|
|
return $this->where('role_id', $roleId)->pluck('menu_id')->toArray();
|
|
}
|
|
}
|