<?php
|
|
namespace app\shop\model\branch;
|
|
use app\common\model\branch\Position as PositionModel;
|
/**
|
* 职务模型
|
*/
|
class Position extends PositionModel
|
{
|
|
/**
|
* 添加新记录
|
*/
|
public function add($data)
|
{
|
$data['app_id'] = self::$app_id;
|
return $this->save($data);
|
}
|
|
/**
|
* 编辑记录
|
*/
|
public function edit($data)
|
{
|
|
$data['update_time'] = time();
|
return $this->save($data);
|
}
|
|
/**
|
* 删除
|
*/
|
public function remove()
|
{
|
// 判断是否存在
|
$Count = (new Member())->where('position_id','=' ,$this['position_id'])->where('is_delete','=', 0)->count();
|
if ($Count > 0) {
|
$this->error = '该职务使用中,不允许删除';
|
return false;
|
}
|
return $this->delete();
|
}
|
|
/**
|
* 开启禁止
|
*/
|
public function setStatus($status)
|
{
|
// 开启事务
|
$this->startTrans();
|
try {
|
//更改分会状态
|
$this->save(['status' => $status]);
|
$this->commit();
|
return true;
|
} catch (\Exception $e) {
|
$this->error = $e->getMessage();
|
$this->rollback();
|
return false;
|
}
|
}
|
}
|