2025-05-12 00:19:35 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
|
|
use App\BaseApp\BaseModel;
|
2026-08-14 23:21:21 +08:00
|
|
|
|
use App\Models\business\DepartmentModel;
|
2025-05-12 13:12:57 +08:00
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
2025-05-12 00:19:35 +08:00
|
|
|
|
|
2025-05-12 09:04:46 +08:00
|
|
|
|
class AdminModel extends BaseModel
|
2025-05-12 00:19:35 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
2025-05-12 09:04:46 +08:00
|
|
|
|
protected $table = 'admin';
|
2025-05-12 00:19:35 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
|
|
*
|
|
|
|
|
|
* @var list<string>
|
|
|
|
|
|
*/
|
|
|
|
|
|
protected $guarded = [];
|
2025-05-12 13:12:57 +08:00
|
|
|
|
|
|
|
|
|
|
public function role(): HasOne
|
|
|
|
|
|
{
|
|
|
|
|
|
return $this->hasOne(RoleModel::class, 'id', 'role_id');
|
|
|
|
|
|
}
|
2026-08-14 23:21:21 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 所属部门
|
|
|
|
|
|
*
|
|
|
|
|
|
* 部门表在 business 连接(cc_ 前缀),Eloquent 关联可以跨连接,
|
|
|
|
|
|
* 但不能和本表做 SQL join,需要 join 时只能分两次查再在 PHP 里拼。
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function department(): HasOne
|
|
|
|
|
|
{
|
|
|
|
|
|
return $this->hasOne(DepartmentModel::class, 'id', 'department_id');
|
|
|
|
|
|
}
|
2025-05-12 00:19:35 +08:00
|
|
|
|
}
|