[Staff]用户

This commit is contained in:
2025-06-21 12:56:15 +08:00
parent 900e42f1db
commit 1ab1a3a293
6 changed files with 436 additions and 0 deletions

View File

@ -3,6 +3,7 @@
namespace jerryyan\staff\model;
use think\admin\Model;
use think\db\Query;
use think\model\relation\HasMany;
use think\model\relation\HasOne;
@ -12,6 +13,22 @@ class StaffDept extends Model
protected $updateTime = false;
protected $oplogName = '部门';
protected $oplogType = '部门管理';
protected $globalScope = ['not_deleted'];
public function scopeDeleted(Query $query): void
{
$query->where(['is_deleted' => 1]);
}
public function scopeNotDeleted(Query $query): void
{
$query->where(['is_deleted' => 0]);
}
public static function items()
{
return self::mk()->where(['status' => 1])->select();
}
public function staffs(): HasMany
{
@ -36,4 +53,9 @@ class StaffDept extends Model
{
return $this->hasOne(StaffDept::class, 'id', 'pid');
}
public static function tree()
{
return static::mk()->where(['is_deleted' => 0, 'pid' => 0])->with('children.children')->select();
}
}