feat : role
This commit is contained in:
39
app/Model/AdminRoleMenu.php
Normal file
39
app/Model/AdminRoleMenu.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user