38 lines
868 B
PHP
38 lines
868 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
use Hyperf\DbConnection\Db;
|
|
|
|
/**
|
|
* @property int $account_id
|
|
* @property int $role_id
|
|
*/
|
|
class AccountRole extends Model
|
|
{
|
|
/**
|
|
* The table associated with the model.
|
|
*/
|
|
protected ?string $table = 'account_role';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected array $fillable = [];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*/
|
|
protected array $casts = ['account_id' => 'integer', 'role_id' => 'integer'];
|
|
|
|
public static function getRole(int $account_id)
|
|
{
|
|
return Db::table("account_role")
|
|
->leftJoin('role', 'role.role_id', '=', 'account_role.role_id')
|
|
->where('account_role.account_id', $account_id)
|
|
->select(["role.role_id","role.role_name"])->get()->toArray();
|
|
}
|
|
}
|