server/app/Model/RoleMenu.php

38 lines
835 B
PHP

<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\DbConnection\Db;
/**
* @property int $role_id
* @property int $menu_id
*/
class RoleMenu extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = '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'];
public static function getMenu(int $role_id)
{
return Db::table("role_menu")
->leftJoin('menu', 'menu.menu_id', '=', 'role_menu.menu_id')
->where('role_menu.role_id', $role_id)
->select(["menu.menu_id", "menu.title"])->get()->toArray();
}
}