用户管理
This commit is contained in:
@@ -19,7 +19,7 @@ trait BaseOptionsTrait
|
||||
}
|
||||
|
||||
if ($this->save()) {
|
||||
return $this->id;
|
||||
return $this->{$this->getPk()};
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -42,7 +42,7 @@ trait BaseOptionsTrait
|
||||
}
|
||||
|
||||
if ($model->save()) {
|
||||
$model->id;
|
||||
return $model->id;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -53,21 +53,37 @@ trait BaseOptionsTrait
|
||||
* @time 2019年12月03日
|
||||
* @param $id
|
||||
* @param array $field
|
||||
* @param bool $trash
|
||||
* @return mixed
|
||||
*/
|
||||
public function findBy($id, array $field = ['*'])
|
||||
public function findBy($id, array $field = ['*'], $trash = false)
|
||||
{
|
||||
return static::where($this->getPk(), $id)->select($field)->find();
|
||||
if ($trash) {
|
||||
return static::onlyTrashed()->find($id);
|
||||
}
|
||||
|
||||
return static::where($this->getPk(), $id)->field($field)->find();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @time 2019年12月03日
|
||||
* @param $id
|
||||
* @param $force
|
||||
* @return mixed
|
||||
*/
|
||||
public function deleteBy($id)
|
||||
public function deleteBy($id, $force = false)
|
||||
{
|
||||
return static::destory($id);
|
||||
return static::destroy($id, $force);
|
||||
}
|
||||
|
||||
/**
|
||||
* @time 2019年12月07日
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function recover($id)
|
||||
{
|
||||
return static::onlyTrashed()->find($id)->restore();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user