再次优化

This commit is contained in:
阿不叮咚
2025-09-24 15:51:38 +08:00
parent edd4effc95
commit 998f8d8356
3 changed files with 15 additions and 10 deletions

View File

@@ -60,9 +60,9 @@ abstract class AbstractModel extends AetherModel
* @param array $columns
* @return AbstractModel
*/
public static function findOrFail(int $id, $columns = []): self
public static function findOrFail(mixed $id, $columns = []): self
{
$model = self::find($id);
$model = self::find($id, $columns);
if (!$model) {
throw new ModelNotFoundException();
}
@@ -74,10 +74,7 @@ abstract class AbstractModel extends AetherModel
*/
public static function createOne(array $data): self
{
$model = new static();
$model->fill($data);
$model->save();
return $model;
return static::query()->create($data);
}
/**