You've already forked jianlizaojia
[Staff]Init
This commit is contained in:
39
plugs/think-plugs-staff/src/model/StaffDept.php
Normal file
39
plugs/think-plugs-staff/src/model/StaffDept.php
Normal 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');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user