[Staff]Init

This commit is contained in:
2025-06-20 18:57:40 +08:00
parent c57ae846e3
commit 900e42f1db
8 changed files with 231 additions and 1 deletions

View File

@ -0,0 +1,39 @@
<?php
namespace jerryyan\staff\model;
use think\admin\Model;
use think\model\relation\HasMany;
use think\model\relation\HasOne;
class StaffDept extends Model
{
protected $createTime = 'create_at';
protected $updateTime = false;
protected $oplogName = '部门';
protected $oplogType = '部门管理';
public function staffs(): HasMany
{
return $this->hasMany(StaffUser::class, 'dept_id', 'id')->where([
'status' => 1, 'is_deleted' => 0,
]);
}
public function headman(): HasOne
{
return $this->hasOne(StaffUser::class, 'id', 'headman_id')->where([
'status' => 1, 'is_deleted' => 0,
]);
}
public function children(): HasMany
{
return $this->hasMany(StaffDept::class, 'pid', 'id');
}
public function parent(): HasOne
{
return $this->hasOne(StaffDept::class, 'id', 'pid');
}
}