mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-16 12:08:12 +00:00
52 lines
1.8 KiB
PHP
52 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
/**
|
|
* App\Models\UserDepartment
|
|
*
|
|
* @property int $id
|
|
* @property string|null $name 部门名称
|
|
* @property int|null $dialog_id 聊天会话ID
|
|
* @property int|null $parent_id 上级部门
|
|
* @property int|null $owner_userid 部门负责人
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserDepartment newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserDepartment newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserDepartment query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserDepartment whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserDepartment whereDialogId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserDepartment whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserDepartment whereName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserDepartment whereOwnerUserid($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserDepartment whereParentId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserDepartment whereUpdatedAt($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class UserDepartment extends AbstractModel
|
|
{
|
|
|
|
/**
|
|
* 保存部门
|
|
* @return bool
|
|
*/
|
|
public function saveDepartment() {
|
|
// todo 聊天室相关
|
|
return $this->save();
|
|
}
|
|
|
|
/**
|
|
* 删除部门
|
|
* @return void
|
|
*/
|
|
public function deleteDepartment() {
|
|
$list = self::whereParentId($this->id)->get();
|
|
foreach ($list as $item) {
|
|
$item->deleteDepartment();
|
|
}
|
|
// todo 移动成员
|
|
$this->delete();
|
|
}
|
|
}
|