用户管理

This commit is contained in:
wuyanwen
2019-12-07 17:31:38 +08:00
parent fa4837487b
commit 330a19e8c3
35 changed files with 1181 additions and 214 deletions

View File

@@ -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();
}
}