Files
lgp-admin-plus-api/app/Models/AdminModel.php

36 lines
816 B
PHP
Raw Normal View History

2025-05-12 00:19:35 +08:00
<?php
namespace App\Models;
use App\BaseApp\BaseModel;
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');
}
/**
* 所属部门
*
* 部门表在 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
}