更新
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
namespace app\model;
|
||||
|
||||
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
|
||||
class Department extends Model
|
||||
|
||||
{
|
||||
|
||||
protected $name = 'departments';
|
||||
|
||||
protected $autoWriteTimestamp = true;
|
||||
|
||||
protected $createTime = 'created_at';
|
||||
|
||||
protected $updateTime = 'updated_at';
|
||||
|
||||
|
||||
|
||||
public function parent()
|
||||
|
||||
{
|
||||
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function children()
|
||||
|
||||
{
|
||||
|
||||
return $this->hasMany(self::class, 'parent_id');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user