发布推送
This commit is contained in:
@ -32,14 +32,16 @@ class BaseModel extends Model
|
||||
return $this->newQuery()->where($this->primaryKey, $id)->delete();
|
||||
}
|
||||
|
||||
function updateItem($aItem): bool|int
|
||||
function updateItem($aItem,$col = null): bool|int
|
||||
{
|
||||
if(!$col) $col = $this->primaryKey;
|
||||
$aItem = $this->checkColInFill($aItem);
|
||||
if (empty($aItem)) return false;
|
||||
if (isset($aItem[$this->primaryKey])) return false;
|
||||
return $this->newQuery()->where($this->primaryKey,$aItem[$this->primaryKey])->update($aItem);
|
||||
if (isset($aItem[$col])) return false;
|
||||
return $this->newQuery()->where($col,$aItem[$col])->update($aItem);
|
||||
}
|
||||
|
||||
|
||||
function findItem($id,$col=['*']): Model|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Builder|array|null
|
||||
{
|
||||
return $this->newQuery()->find($id,$col);
|
||||
|
||||
Reference in New Issue
Block a user