You've already forked jianlizaojia
[Staff]用户
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user