From 8fc95ef455df6f73f7bc4c1dfed2e92e756ad643 Mon Sep 17 00:00:00 2001 From: Luke Kuzmish Date: Mon, 11 Nov 2024 21:44:41 -0500 Subject: [PATCH] clean up from IDE changes --- src/Illuminate/Database/Eloquent/Model.php | 69 +++++++++++----------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/src/Illuminate/Database/Eloquent/Model.php b/src/Illuminate/Database/Eloquent/Model.php index 919b3b6e5d6..7fdc0f1601e 100644 --- a/src/Illuminate/Database/Eloquent/Model.php +++ b/src/Illuminate/Database/Eloquent/Model.php @@ -275,7 +275,7 @@ public function __construct(array $attributes = []) */ protected function bootIfNotBooted() { - if (!isset(static::$booted[static::class])) { + if (! isset(static::$booted[static::class])) { static::$booted[static::class] = true; $this->fireModelEvent('booting', false); @@ -324,7 +324,7 @@ protected static function bootTraits() foreach (class_uses_recursive($class) as $trait) { $method = 'boot'.class_basename($trait); - if (method_exists($class, $method) && !in_array($method, $booted)) { + if (method_exists($class, $method) && ! in_array($method, $booted)) { forward_static_call([$class, $method]); $booted[] = $method; @@ -413,7 +413,7 @@ public static function isIgnoringTouch($class = null) { $class = $class ?: static::class; - if (!get_class_vars($class)['timestamps'] || !$class::UPDATED_AT) { + if (! get_class_vars($class)['timestamps'] || ! $class::UPDATED_AT) { return true; } @@ -586,7 +586,7 @@ public function fill(array $attributes) */ public function forceFill(array $attributes) { - return static::unguarded(fn() => $this->fill($attributes)); + return static::unguarded(fn () => $this->fill($attributes)); } /** @@ -746,7 +746,7 @@ public function load($relations) */ public function loadMorph($relation, $relations) { - if (!$this->{$relation}) { + if (! $this->{$relation}) { return $this; } @@ -870,7 +870,7 @@ public function loadExists($relations) */ public function loadMorphAggregate($relation, $relations, $column, $function = null) { - if (!$this->{$relation}) { + if (! $this->{$relation}) { return $this; } @@ -982,7 +982,7 @@ protected function decrement($column, $amount = 1, array $extra = []) */ protected function incrementOrDecrement($column, $amount, $extra, $method) { - if (!$this->exists) { + if (! $this->exists) { return $this->newQueryWithoutRelationships()->{$method}($column, $amount, $extra); } @@ -1000,14 +1000,13 @@ protected function incrementOrDecrement($column, $amount, $extra, $method) $amount = (clone $this)->setAttribute($column, $amount)->getAttributeFromArray($column); } - return tap($this->setKeysForSaveQuery($this->newQueryWithoutScopes())->{$method}($column, $amount, $extra), - function () use ($column) { - $this->syncChanges(); + return tap($this->setKeysForSaveQuery($this->newQueryWithoutScopes())->{$method}($column, $amount, $extra), function () use ($column) { + $this->syncChanges(); - $this->fireModelEvent('updated', false); + $this->fireModelEvent('updated', false); - $this->syncOriginalAttribute($column); - }); + $this->syncOriginalAttribute($column); + }); } /** @@ -1019,7 +1018,7 @@ function () use ($column) { */ public function update(array $attributes = [], array $options = []) { - if (!$this->exists) { + if (! $this->exists) { return false; } @@ -1037,7 +1036,7 @@ public function update(array $attributes = [], array $options = []) */ public function updateOrFail(array $attributes = [], array $options = []) { - if (!$this->exists) { + if (! $this->exists) { return false; } @@ -1053,7 +1052,7 @@ public function updateOrFail(array $attributes = [], array $options = []) */ public function updateQuietly(array $attributes = [], array $options = []) { - if (!$this->exists) { + if (! $this->exists) { return false; } @@ -1098,7 +1097,7 @@ protected function decrementQuietly($column, $amount = 1, array $extra = []) public function push() { return $this->withoutRecursion(function () { - if (!$this->save()) { + if (! $this->save()) { return false; } @@ -1110,7 +1109,7 @@ public function push() ? $models->all() : [$models]; foreach (array_filter($models) as $model) { - if (!$model->push()) { + if (! $model->push()) { return false; } } @@ -1127,7 +1126,7 @@ public function push() */ public function pushQuietly() { - return static::withoutEvents(fn() => $this->push()); + return static::withoutEvents(fn () => $this->push()); } /** @@ -1138,7 +1137,7 @@ public function pushQuietly() */ public function saveQuietly(array $options = []) { - return static::withoutEvents(fn() => $this->save($options)); + return static::withoutEvents(fn () => $this->save($options)); } /** @@ -1174,7 +1173,7 @@ public function save(array $options = []) else { $saved = $this->performInsert($query); - if (!$this->getConnectionName() && + if (! $this->getConnectionName() && $connection = $query->getConnection()) { $this->setConnection($connection->getName()); } @@ -1200,7 +1199,7 @@ public function save(array $options = []) */ public function saveOrFail(array $options = []) { - return $this->getConnection()->transaction(fn() => $this->save($options)); + return $this->getConnection()->transaction(fn () => $this->save($options)); } /** @@ -1429,7 +1428,7 @@ public function delete() // If the model doesn't exist, there is nothing to delete so we'll just return // immediately and not do anything else. Otherwise, we will continue with a // deletion process on the model, firing the proper events, and so forth. - if (!$this->exists) { + if (! $this->exists) { return; } @@ -1459,7 +1458,7 @@ public function delete() */ public function deleteQuietly() { - return static::withoutEvents(fn() => $this->delete()); + return static::withoutEvents(fn () => $this->delete()); } /** @@ -1471,11 +1470,11 @@ public function deleteQuietly() */ public function deleteOrFail() { - if (!$this->exists) { + if (! $this->exists) { return false; } - return $this->getConnection()->transaction(fn() => $this->delete()); + return $this->getConnection()->transaction(fn () => $this->delete()); } /** @@ -1674,8 +1673,8 @@ public function callNamedScope($scope, array $parameters = []) public function toArray() { return $this->withoutRecursion( - fn() => array_merge($this->attributesToArray(), $this->relationsToArray()), - fn() => $this->attributesToArray(), + fn () => array_merge($this->attributesToArray(), $this->relationsToArray()), + fn () => $this->attributesToArray(), ); } @@ -1716,7 +1715,7 @@ public function jsonSerialize(): mixed */ public function fresh($with = []) { - if (!$this->exists) { + if (! $this->exists) { return; } @@ -1733,7 +1732,7 @@ public function fresh($with = []) */ public function refresh() { - if (!$this->exists) { + if (! $this->exists) { return $this; } @@ -1791,7 +1790,7 @@ public function replicate(?array $except = null) */ public function replicateQuietly(?array $except = null) { - return static::withoutEvents(fn() => $this->replicate($except)); + return static::withoutEvents(fn () => $this->replicate($except)); } /** @@ -1802,7 +1801,7 @@ public function replicateQuietly(?array $except = null) */ public function is($model) { - return !is_null($model) && + return ! is_null($model) && $this->getKey() === $model->getKey() && $this->getTable() === $model->getTable() && $this->getConnectionName() === $model->getConnectionName(); @@ -1816,7 +1815,7 @@ public function is($model) */ public function isNot($model) { - return !$this->is($model); + return ! $this->is($model); } /** @@ -2027,7 +2026,7 @@ public function getQueueableRelations() $relations = []; foreach ($this->getRelations() as $key => $relation) { - if (!method_exists($this, $key)) { + if (! method_exists($this, $key)) { continue; } @@ -2312,7 +2311,7 @@ public function __set($key, $value) public function offsetExists($offset): bool { try { - return !is_null($this->getAttribute($offset)); + return ! is_null($this->getAttribute($offset)); } catch (MissingAttributeException) { return false; }