新增禁用/启用
This commit is contained in:
parent
f2affda157
commit
655541210a
@ -17,6 +17,7 @@ namespace catcher\base;
|
|||||||
* @method updateBy(int $id, array $data)
|
* @method updateBy(int $id, array $data)
|
||||||
* @method findBy(int $id, array $column = ['*'])
|
* @method findBy(int $id, array $column = ['*'])
|
||||||
* @method deleteBy(int $id)
|
* @method deleteBy(int $id)
|
||||||
|
* @method disOrEnable(int $id)
|
||||||
* @method startTrans()
|
* @method startTrans()
|
||||||
* @method rollback()
|
* @method rollback()
|
||||||
* @method commit()
|
* @method commit()
|
||||||
|
@ -155,4 +155,23 @@ trait BaseOptionsTrait
|
|||||||
{
|
{
|
||||||
return sprintf('%s.%s', $this->getTable(), $field);
|
return sprintf('%s.%s', $this->getTable(), $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 禁用/启用
|
||||||
|
*
|
||||||
|
* @time 2020年06月29日
|
||||||
|
* @param $id
|
||||||
|
* @param string $field
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function disOrEnable($id, $field='status')
|
||||||
|
{
|
||||||
|
$model = $this->findBy($id);
|
||||||
|
|
||||||
|
$status = $model->{$field} == self::DISABLE ? self::ENABLE : self::DISABLE;
|
||||||
|
|
||||||
|
$model->{$field} = $status;
|
||||||
|
|
||||||
|
return $model->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user