@@ -3,9 +3,9 @@ |
||
3 | 3 | namespace Illuminate\Database\Eloquent\Concerns; |
4 | 4 | |
5 | 5 | use Closure; |
6 | +use Illuminate\Database\Eloquent\Scope; |
|
6 | 7 | use Illuminate\Support\Arr; |
7 | 8 | use InvalidArgumentException; |
8 | -use Illuminate\Database\Eloquent\Scope; |
|
9 | 9 | |
10 | 10 | trait HasGlobalScopes |
11 | 11 | { |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public static function addGlobalScope($scope, Closure $implementation = null) |
22 | 22 | { |
23 | - if (is_string($scope) && ! is_null($implementation)) { |
|
23 | + if (is_string($scope) && !is_null($implementation)) { |
|
24 | 24 | return static::$globalScopes[static::class][$scope] = $implementation; |
25 | 25 | } elseif ($scope instanceof Closure) { |
26 | 26 | return static::$globalScopes[static::class][spl_object_hash($scope)] = $scope; |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public static function hasGlobalScope($scope) |
41 | 41 | { |
42 | - return ! is_null(static::getGlobalScope($scope)); |
|
42 | + return !is_null(static::getGlobalScope($scope)); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * @param string $name |
623 | 623 | * @param string $type |
624 | 624 | * @param string $id |
625 | - * @return array |
|
625 | + * @return string[] |
|
626 | 626 | */ |
627 | 627 | protected function getMorphs($name, $type, $id) |
628 | 628 | { |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | * Set the given relationship on the model. |
697 | 697 | * |
698 | 698 | * @param string $relation |
699 | - * @param mixed $value |
|
699 | + * @param Model|null $value |
|
700 | 700 | * @return $this |
701 | 701 | */ |
702 | 702 | public function setRelation($relation, $value) |
@@ -2,21 +2,21 @@ |
||
2 | 2 | |
3 | 3 | namespace Illuminate\Database\Eloquent\Concerns; |
4 | 4 | |
5 | -use Illuminate\Support\Arr; |
|
6 | -use Illuminate\Support\Str; |
|
7 | -use Illuminate\Database\Eloquent\Model; |
|
8 | 5 | use Illuminate\Database\Eloquent\Builder; |
9 | 6 | use Illuminate\Database\Eloquent\Collection; |
10 | -use Illuminate\Database\Eloquent\Relations\HasOne; |
|
11 | -use Illuminate\Database\Eloquent\Relations\HasMany; |
|
12 | -use Illuminate\Database\Eloquent\Relations\MorphTo; |
|
13 | -use Illuminate\Database\Eloquent\Relations\MorphOne; |
|
14 | -use Illuminate\Database\Eloquent\Relations\Relation; |
|
7 | +use Illuminate\Database\Eloquent\Model; |
|
15 | 8 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
16 | -use Illuminate\Database\Eloquent\Relations\MorphMany; |
|
17 | -use Illuminate\Database\Eloquent\Relations\MorphToMany; |
|
18 | 9 | use Illuminate\Database\Eloquent\Relations\BelongsToMany; |
10 | +use Illuminate\Database\Eloquent\Relations\HasMany; |
|
19 | 11 | use Illuminate\Database\Eloquent\Relations\HasManyThrough; |
12 | +use Illuminate\Database\Eloquent\Relations\HasOne; |
|
13 | +use Illuminate\Database\Eloquent\Relations\MorphMany; |
|
14 | +use Illuminate\Database\Eloquent\Relations\MorphOne; |
|
15 | +use Illuminate\Database\Eloquent\Relations\MorphTo; |
|
16 | +use Illuminate\Database\Eloquent\Relations\MorphToMany; |
|
17 | +use Illuminate\Database\Eloquent\Relations\Relation; |
|
18 | +use Illuminate\Support\Arr; |
|
19 | +use Illuminate\Support\Str; |
|
20 | 20 | |
21 | 21 | trait HasRelationships |
22 | 22 | { |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
404 | 404 | */ |
405 | 405 | public function belongsToMany($related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null, |
406 | - $parentKey = null, $relatedKey = null, $relation = null) |
|
406 | + $parentKey = null, $relatedKey = null, $relation = null) |
|
407 | 407 | { |
408 | 408 | // If no relationship name was passed, we will pull backtraces to get the |
409 | 409 | // name of the calling function. We will use that function name as the |
@@ -510,8 +510,8 @@ discard block |
||
510 | 510 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
511 | 511 | */ |
512 | 512 | protected function newMorphToMany(Builder $query, Model $parent, $name, $table, $foreignPivotKey, |
513 | - $relatedPivotKey, $parentKey, $relatedKey, |
|
514 | - $relationName = null, $inverse = false) |
|
513 | + $relatedPivotKey, $parentKey, $relatedKey, |
|
514 | + $relationName = null, $inverse = false) |
|
515 | 515 | { |
516 | 516 | return new MorphToMany($query, $parent, $name, $table, $foreignPivotKey, $relatedPivotKey, $parentKey, $relatedKey, |
517 | 517 | $relationName, $inverse); |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
531 | 531 | */ |
532 | 532 | public function morphedByMany($related, $name, $table = null, $foreignPivotKey = null, |
533 | - $relatedPivotKey = null, $parentKey = null, $relatedKey = null) |
|
533 | + $relatedPivotKey = null, $parentKey = null, $relatedKey = null) |
|
534 | 534 | { |
535 | 535 | $foreignPivotKey = $foreignPivotKey ?: $this->getForeignKey(); |
536 | 536 |
@@ -552,11 +552,11 @@ discard block |
||
552 | 552 | */ |
553 | 553 | protected function guessBelongsToManyRelation() |
554 | 554 | { |
555 | - $caller = Arr::first(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), function ($trace) { |
|
556 | - return ! in_array($trace['function'], Model::$manyMethods); |
|
555 | + $caller = Arr::first(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), function($trace){ |
|
556 | + return !in_array($trace['function'], Model::$manyMethods); |
|
557 | 557 | }); |
558 | 558 | |
559 | - return ! is_null($caller) ? $caller['function'] : null; |
|
559 | + return !is_null($caller) ? $caller['function'] : null; |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | /** |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | |
610 | 610 | $this->$relation->touchOwners(); |
611 | 611 | } elseif ($this->$relation instanceof Collection) { |
612 | - $this->$relation->each(function (Model $relation) { |
|
612 | + $this->$relation->each(function(Model $relation){ |
|
613 | 613 | $relation->touchOwners(); |
614 | 614 | }); |
615 | 615 | } |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | { |
639 | 639 | $morphMap = Relation::morphMap(); |
640 | 640 | |
641 | - if (! empty($morphMap) && in_array(static::class, $morphMap)) { |
|
641 | + if (!empty($morphMap) && in_array(static::class, $morphMap)) { |
|
642 | 642 | return array_search(static::class, $morphMap, true); |
643 | 643 | } |
644 | 644 | |
@@ -653,8 +653,8 @@ discard block |
||
653 | 653 | */ |
654 | 654 | protected function newRelatedInstance($class) |
655 | 655 | { |
656 | - return tap(new $class, function ($instance) { |
|
657 | - if (! $instance->getConnectionName()) { |
|
656 | + return tap(new $class, function($instance){ |
|
657 | + if (!$instance->getConnectionName()) { |
|
658 | 658 | $instance->setConnection($this->connection); |
659 | 659 | } |
660 | 660 | }); |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | */ |
553 | 553 | protected function guessBelongsToManyRelation() |
554 | 554 | { |
555 | - $caller = Arr::first(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), function ($trace) { |
|
555 | + $caller = Arr::first(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), function ($trace){ |
|
556 | 556 | return ! in_array($trace['function'], Model::$manyMethods); |
557 | 557 | }); |
558 | 558 | |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | |
610 | 610 | $this->$relation->touchOwners(); |
611 | 611 | } elseif ($this->$relation instanceof Collection) { |
612 | - $this->$relation->each(function (Model $relation) { |
|
612 | + $this->$relation->each(function (Model $relation){ |
|
613 | 613 | $relation->touchOwners(); |
614 | 614 | }); |
615 | 615 | } |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | */ |
654 | 654 | protected function newRelatedInstance($class) |
655 | 655 | { |
656 | - return tap(new $class, function ($instance) { |
|
656 | + return tap(new $class, function ($instance){ |
|
657 | 657 | if (! $instance->getConnectionName()) { |
658 | 658 | $instance->setConnection($this->connection); |
659 | 659 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * Set the value of the "created at" attribute. |
53 | 53 | * |
54 | - * @param mixed $value |
|
54 | + * @param Carbon $value |
|
55 | 55 | * @return $this |
56 | 56 | */ |
57 | 57 | public function setCreatedAt($value) |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | /** |
65 | 65 | * Set the value of the "updated at" attribute. |
66 | 66 | * |
67 | - * @param mixed $value |
|
67 | + * @param Carbon $value |
|
68 | 68 | * @return $this |
69 | 69 | */ |
70 | 70 | public function setUpdatedAt($value) |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function touch() |
22 | 22 | { |
23 | - if (! $this->usesTimestamps()) { |
|
23 | + if (!$this->usesTimestamps()) { |
|
24 | 24 | return false; |
25 | 25 | } |
26 | 26 | |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | { |
39 | 39 | $time = $this->freshTimestamp(); |
40 | 40 | |
41 | - if (! is_null(static::UPDATED_AT) && ! $this->isDirty(static::UPDATED_AT)) { |
|
41 | + if (!is_null(static::UPDATED_AT) && !$this->isDirty(static::UPDATED_AT)) { |
|
42 | 42 | $this->setUpdatedAt($time); |
43 | 43 | } |
44 | 44 | |
45 | - if (! $this->exists && ! is_null(static::CREATED_AT) && |
|
46 | - ! $this->isDirty(static::CREATED_AT)) { |
|
45 | + if (!$this->exists && !is_null(static::CREATED_AT) && |
|
46 | + !$this->isDirty(static::CREATED_AT)) { |
|
47 | 47 | $this->setCreatedAt($time); |
48 | 48 | } |
49 | 49 | } |
@@ -3,13 +3,13 @@ |
||
3 | 3 | namespace Illuminate\Database\Eloquent\Concerns; |
4 | 4 | |
5 | 5 | use Closure; |
6 | -use RuntimeException; |
|
7 | -use Illuminate\Support\Str; |
|
8 | 6 | use Illuminate\Database\Eloquent\Builder; |
9 | -use Illuminate\Database\Query\Expression; |
|
10 | 7 | use Illuminate\Database\Eloquent\Relations\MorphTo; |
11 | 8 | use Illuminate\Database\Eloquent\Relations\Relation; |
12 | 9 | use Illuminate\Database\Query\Builder as QueryBuilder; |
10 | +use Illuminate\Database\Query\Expression; |
|
11 | +use Illuminate\Support\Str; |
|
12 | +use RuntimeException; |
|
13 | 13 | |
14 | 14 | trait QueriesRelationships |
15 | 15 | { |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | { |
75 | 75 | $relations = explode('.', $relations); |
76 | 76 | |
77 | - $closure = function ($q) use (&$closure, &$relations, $operator, $count, $callback) { |
|
77 | + $closure = function($q) use (&$closure, &$relations, $operator, $count, $callback) { |
|
78 | 78 | // In order to nest "has", we need to add count relation constraints on the |
79 | 79 | // callback Closure. We'll do this by simply passing the Closure its own |
80 | 80 | // reference to itself so it calls itself recursively on each segment. |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | */ |
302 | 302 | protected function getRelationWithoutConstraints($relation) |
303 | 303 | { |
304 | - return Relation::noConstraints(function () use ($relation) { |
|
304 | + return Relation::noConstraints(function() use ($relation) { |
|
305 | 305 | return $this->getModel()->{$relation}(); |
306 | 306 | }); |
307 | 307 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | { |
75 | 75 | $relations = explode('.', $relations); |
76 | 76 | |
77 | - $closure = function ($q) use (&$closure, &$relations, $operator, $count, $callback) { |
|
77 | + $closure = function ($q) use (&$closure, &$relations, $operator, $count, $callback){ |
|
78 | 78 | // In order to nest "has", we need to add count relation constraints on the |
79 | 79 | // callback Closure. We'll do this by simply passing the Closure its own |
80 | 80 | // reference to itself so it calls itself recursively on each segment. |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | */ |
302 | 302 | protected function getRelationWithoutConstraints($relation) |
303 | 303 | { |
304 | - return Relation::noConstraints(function () use ($relation) { |
|
304 | + return Relation::noConstraints(function () use ($relation){ |
|
305 | 305 | return $this->getModel()->{$relation}(); |
306 | 306 | }); |
307 | 307 | } |
@@ -306,7 +306,7 @@ |
||
306 | 306 | * |
307 | 307 | * @param string $offset |
308 | 308 | * @param callable $value |
309 | - * @return void |
|
309 | + * @return Factory |
|
310 | 310 | */ |
311 | 311 | public function offsetSet($offset, $value) |
312 | 312 | { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | /** |
132 | 132 | * Set the states to be applied to the model. |
133 | 133 | * |
134 | - * @param array|mixed $states |
|
134 | + * @param string[] $states |
|
135 | 135 | * @return $this |
136 | 136 | */ |
137 | 137 | public function states($states) |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * Create a collection of models. |
212 | 212 | * |
213 | 213 | * @param array $attributes |
214 | - * @return mixed |
|
214 | + * @return \Illuminate\Support\Collection |
|
215 | 215 | */ |
216 | 216 | public function make(array $attributes = []) |
217 | 217 | { |
@@ -3,8 +3,8 @@ |
||
3 | 3 | namespace Illuminate\Database\Eloquent; |
4 | 4 | |
5 | 5 | use Faker\Generator as Faker; |
6 | -use InvalidArgumentException; |
|
7 | 6 | use Illuminate\Support\Traits\Macroable; |
7 | +use InvalidArgumentException; |
|
8 | 8 | |
9 | 9 | class FactoryBuilder |
10 | 10 | { |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function lazy(array $attributes = []) |
164 | 164 | { |
165 | - return function () use ($attributes) { |
|
165 | + return function() use ($attributes) { |
|
166 | 166 | return $this->create($attributes); |
167 | 167 | }; |
168 | 168 | } |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | */ |
199 | 199 | protected function store($results) |
200 | 200 | { |
201 | - $results->each(function ($model) { |
|
202 | - if (! isset($this->connection)) { |
|
201 | + $results->each(function($model){ |
|
202 | + if (!isset($this->connection)) { |
|
203 | 203 | $model->setConnection($model->newQueryWithoutScopes()->getConnection()->getName()); |
204 | 204 | } |
205 | 205 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | public function make(array $attributes = []) |
217 | 217 | { |
218 | 218 | if ($this->amount === null) { |
219 | - return tap($this->makeInstance($attributes), function ($instance) { |
|
219 | + return tap($this->makeInstance($attributes), function($instance){ |
|
220 | 220 | $this->callAfterMaking(collect([$instance])); |
221 | 221 | }); |
222 | 222 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | return (new $this->class)->newCollection(); |
226 | 226 | } |
227 | 227 | |
228 | - $instances = (new $this->class)->newCollection(array_map(function () use ($attributes) { |
|
228 | + $instances = (new $this->class)->newCollection(array_map(function() use ($attributes) { |
|
229 | 229 | return $this->makeInstance($attributes); |
230 | 230 | }, range(1, $this->amount))); |
231 | 231 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | return []; |
251 | 251 | } |
252 | 252 | |
253 | - return array_map(function () use ($attributes) { |
|
253 | + return array_map(function() use ($attributes) { |
|
254 | 254 | return $this->getRawAttributes($attributes); |
255 | 255 | }, range(1, $this->amount)); |
256 | 256 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | protected function getRawAttributes(array $attributes = []) |
267 | 267 | { |
268 | - if (! isset($this->definitions[$this->class][$this->name])) { |
|
268 | + if (!isset($this->definitions[$this->class][$this->name])) { |
|
269 | 269 | throw new InvalidArgumentException("Unable to locate factory with name [{$this->name}] [{$this->class}]."); |
270 | 270 | } |
271 | 271 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | protected function makeInstance(array $attributes = []) |
289 | 289 | { |
290 | - return Model::unguarded(function () use ($attributes) { |
|
290 | + return Model::unguarded(function() use ($attributes) { |
|
291 | 291 | $instance = new $this->class( |
292 | 292 | $this->getRawAttributes($attributes) |
293 | 293 | ); |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | protected function applyStates(array $definition, array $attributes = []) |
311 | 311 | { |
312 | 312 | foreach ($this->activeStates as $state) { |
313 | - if (! isset($this->states[$this->class][$state])) { |
|
313 | + if (!isset($this->states[$this->class][$state])) { |
|
314 | 314 | if ($this->stateHasAfterCallback($state)) { |
315 | 315 | continue; |
316 | 316 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | { |
339 | 339 | $stateAttributes = $this->states[$this->class][$state]; |
340 | 340 | |
341 | - if (! is_callable($stateAttributes)) { |
|
341 | + if (!is_callable($stateAttributes)) { |
|
342 | 342 | return $stateAttributes; |
343 | 343 | } |
344 | 344 | |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | protected function expandAttributes(array $attributes) |
358 | 358 | { |
359 | 359 | foreach ($attributes as &$attribute) { |
360 | - if (is_callable($attribute) && ! is_string($attribute) && ! is_array($attribute)) { |
|
360 | + if (is_callable($attribute) && !is_string($attribute) && !is_array($attribute)) { |
|
361 | 361 | $attribute = $attribute($attributes); |
362 | 362 | } |
363 | 363 | |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | { |
407 | 407 | $states = array_merge([$this->name], $this->activeStates); |
408 | 408 | |
409 | - $models->each(function ($model) use ($states, $afterCallbacks) { |
|
409 | + $models->each(function($model) use ($states, $afterCallbacks) { |
|
410 | 410 | foreach ($states as $state) { |
411 | 411 | $this->callAfterCallbacks($afterCallbacks, $model, $state); |
412 | 412 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | */ |
424 | 424 | protected function callAfterCallbacks(array $afterCallbacks, $model, $state) |
425 | 425 | { |
426 | - if (! isset($afterCallbacks[$this->class][$state])) { |
|
426 | + if (!isset($afterCallbacks[$this->class][$state])) { |
|
427 | 427 | return; |
428 | 428 | } |
429 | 429 |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function lazy(array $attributes = []) |
164 | 164 | { |
165 | - return function () use ($attributes) { |
|
165 | + return function () use ($attributes){ |
|
166 | 166 | return $this->create($attributes); |
167 | 167 | }; |
168 | 168 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | protected function store($results) |
200 | 200 | { |
201 | - $results->each(function ($model) { |
|
201 | + $results->each(function ($model){ |
|
202 | 202 | if (! isset($this->connection)) { |
203 | 203 | $model->setConnection($model->newQueryWithoutScopes()->getConnection()->getName()); |
204 | 204 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | public function make(array $attributes = []) |
217 | 217 | { |
218 | 218 | if ($this->amount === null) { |
219 | - return tap($this->makeInstance($attributes), function ($instance) { |
|
219 | + return tap($this->makeInstance($attributes), function ($instance){ |
|
220 | 220 | $this->callAfterMaking(collect([$instance])); |
221 | 221 | }); |
222 | 222 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | return (new $this->class)->newCollection(); |
226 | 226 | } |
227 | 227 | |
228 | - $instances = (new $this->class)->newCollection(array_map(function () use ($attributes) { |
|
228 | + $instances = (new $this->class)->newCollection(array_map(function () use ($attributes){ |
|
229 | 229 | return $this->makeInstance($attributes); |
230 | 230 | }, range(1, $this->amount))); |
231 | 231 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | return []; |
251 | 251 | } |
252 | 252 | |
253 | - return array_map(function () use ($attributes) { |
|
253 | + return array_map(function () use ($attributes){ |
|
254 | 254 | return $this->getRawAttributes($attributes); |
255 | 255 | }, range(1, $this->amount)); |
256 | 256 | } |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | protected function makeInstance(array $attributes = []) |
289 | 289 | { |
290 | - return Model::unguarded(function () use ($attributes) { |
|
290 | + return Model::unguarded(function () use ($attributes){ |
|
291 | 291 | $instance = new $this->class( |
292 | 292 | $this->getRawAttributes($attributes) |
293 | 293 | ); |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | { |
407 | 407 | $states = array_merge([$this->name], $this->activeStates); |
408 | 408 | |
409 | - $models->each(function ($model) use ($states, $afterCallbacks) { |
|
409 | + $models->each(function ($model) use ($states, $afterCallbacks){ |
|
410 | 410 | foreach ($states as $state) { |
411 | 411 | $this->callAfterCallbacks($afterCallbacks, $model, $state); |
412 | 412 | } |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * Increment a column's value by a given amount. |
476 | 476 | * |
477 | 477 | * @param string $column |
478 | - * @param float|int $amount |
|
478 | + * @param integer $amount |
|
479 | 479 | * @param array $extra |
480 | 480 | * @return int |
481 | 481 | */ |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | * Decrement a column's value by a given amount. |
489 | 489 | * |
490 | 490 | * @param string $column |
491 | - * @param float|int $amount |
|
491 | + * @param integer $amount |
|
492 | 492 | * @param array $extra |
493 | 493 | * @return int |
494 | 494 | */ |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * Run the increment or decrement method on the model. |
502 | 502 | * |
503 | 503 | * @param string $column |
504 | - * @param float|int $amount |
|
504 | + * @param integer $amount |
|
505 | 505 | * @param array $extra |
506 | 506 | * @param string $method |
507 | 507 | * @return int |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | /** |
944 | 944 | * Get a new query builder that doesn't have any global scopes. |
945 | 945 | * |
946 | - * @return \Illuminate\Database\Eloquent\Builder|static |
|
946 | + * @return Builder |
|
947 | 947 | */ |
948 | 948 | public function newQueryWithoutScopes() |
949 | 949 | { |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | /** |
1394 | 1394 | * Get the queueable connection for the entity. |
1395 | 1395 | * |
1396 | - * @return mixed |
|
1396 | + * @return string |
|
1397 | 1397 | */ |
1398 | 1398 | public function getQueueableConnection() |
1399 | 1399 | { |
@@ -1490,7 +1490,7 @@ discard block |
||
1490 | 1490 | /** |
1491 | 1491 | * Determine if the given attribute exists. |
1492 | 1492 | * |
1493 | - * @param mixed $offset |
|
1493 | + * @param string $offset |
|
1494 | 1494 | * @return bool |
1495 | 1495 | */ |
1496 | 1496 | public function offsetExists($offset) |
@@ -1524,7 +1524,7 @@ discard block |
||
1524 | 1524 | /** |
1525 | 1525 | * Unset the value for a given offset. |
1526 | 1526 | * |
1527 | - * @param mixed $offset |
|
1527 | + * @param string $offset |
|
1528 | 1528 | * @return void |
1529 | 1529 | */ |
1530 | 1530 | public function offsetUnset($offset) |
@@ -2,19 +2,19 @@ |
||
2 | 2 | |
3 | 3 | namespace Illuminate\Database\Eloquent; |
4 | 4 | |
5 | -use Exception; |
|
6 | 5 | use ArrayAccess; |
7 | -use JsonSerializable; |
|
8 | -use Illuminate\Support\Arr; |
|
9 | -use Illuminate\Support\Str; |
|
10 | -use Illuminate\Contracts\Support\Jsonable; |
|
11 | -use Illuminate\Contracts\Support\Arrayable; |
|
12 | -use Illuminate\Contracts\Routing\UrlRoutable; |
|
6 | +use Exception; |
|
7 | +use Illuminate\Contracts\Queue\QueueableCollection; |
|
13 | 8 | use Illuminate\Contracts\Queue\QueueableEntity; |
9 | +use Illuminate\Contracts\Routing\UrlRoutable; |
|
10 | +use Illuminate\Contracts\Support\Arrayable; |
|
11 | +use Illuminate\Contracts\Support\Jsonable; |
|
12 | +use Illuminate\Database\ConnectionResolverInterface as Resolver; |
|
14 | 13 | use Illuminate\Database\Eloquent\Relations\Pivot; |
15 | -use Illuminate\Contracts\Queue\QueueableCollection; |
|
16 | 14 | use Illuminate\Database\Query\Builder as QueryBuilder; |
17 | -use Illuminate\Database\ConnectionResolverInterface as Resolver; |
|
15 | +use Illuminate\Support\Arr; |
|
16 | +use Illuminate\Support\Str; |
|
17 | +use JsonSerializable; |
|
18 | 18 | |
19 | 19 | abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializable, QueueableEntity, UrlRoutable |
20 | 20 | { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | protected function bootIfNotBooted() |
169 | 169 | { |
170 | - if (! isset(static::$booted[static::class])) { |
|
170 | + if (!isset(static::$booted[static::class])) { |
|
171 | 171 | static::$booted[static::class] = true; |
172 | 172 | |
173 | 173 | $this->fireModelEvent('booting', false); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | foreach (class_uses_recursive($class) as $trait) { |
203 | 203 | $method = 'boot'.class_basename($trait); |
204 | 204 | |
205 | - if (method_exists($class, $method) && ! in_array($method, $booted)) { |
|
205 | + if (method_exists($class, $method) && !in_array($method, $booted)) { |
|
206 | 206 | forward_static_call([$class, $method]); |
207 | 207 | |
208 | 208 | $booted[] = $method; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public function forceFill(array $attributes) |
311 | 311 | { |
312 | - return static::unguarded(function () use ($attributes) { |
|
312 | + return static::unguarded(function() use ($attributes) { |
|
313 | 313 | return $this->fill($attributes); |
314 | 314 | }); |
315 | 315 | } |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | { |
511 | 511 | $query = $this->newQuery(); |
512 | 512 | |
513 | - if (! $this->exists) { |
|
513 | + if (!$this->exists) { |
|
514 | 514 | return $query->{$method}($column, $amount, $extra); |
515 | 515 | } |
516 | 516 | |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | */ |
533 | 533 | protected function incrementOrDecrementAttributeValue($column, $amount, $extra, $method) |
534 | 534 | { |
535 | - $this->{$column} = $this->{$column} + ($method == 'increment' ? $amount : $amount * -1); |
|
535 | + $this->{$column} = $this->{$column} +($method == 'increment' ? $amount : $amount * -1); |
|
536 | 536 | |
537 | 537 | $this->forceFill($extra); |
538 | 538 | |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | */ |
549 | 549 | public function update(array $attributes = [], array $options = []) |
550 | 550 | { |
551 | - if (! $this->exists) { |
|
551 | + if (!$this->exists) { |
|
552 | 552 | return false; |
553 | 553 | } |
554 | 554 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | */ |
563 | 563 | public function push() |
564 | 564 | { |
565 | - if (! $this->save()) { |
|
565 | + if (!$this->save()) { |
|
566 | 566 | return false; |
567 | 567 | } |
568 | 568 | |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | ? $models->all() : [$models]; |
575 | 575 | |
576 | 576 | foreach (array_filter($models) as $model) { |
577 | - if (! $model->push()) { |
|
577 | + if (!$model->push()) { |
|
578 | 578 | return false; |
579 | 579 | } |
580 | 580 | } |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | else { |
615 | 615 | $saved = $this->performInsert($query); |
616 | 616 | |
617 | - if (! $this->getConnectionName() && |
|
617 | + if (!$this->getConnectionName() && |
|
618 | 618 | $connection = $query->getConnection()) { |
619 | 619 | $this->setConnection($connection->getName()); |
620 | 620 | } |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | */ |
641 | 641 | public function saveOrFail(array $options = []) |
642 | 642 | { |
643 | - return $this->getConnection()->transaction(function () use ($options) { |
|
643 | + return $this->getConnection()->transaction(function() use ($options) { |
|
644 | 644 | return $this->save($options); |
645 | 645 | }); |
646 | 646 | } |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | // If the model doesn't exist, there is nothing to delete so we'll just return |
835 | 835 | // immediately and not do anything else. Otherwise, we will continue with a |
836 | 836 | // deletion process on the model, firing the proper events, and so forth. |
837 | - if (! $this->exists) { |
|
837 | + if (!$this->exists) { |
|
838 | 838 | return; |
839 | 839 | } |
840 | 840 | |
@@ -1075,7 +1075,7 @@ discard block |
||
1075 | 1075 | */ |
1076 | 1076 | public function fresh($with = []) |
1077 | 1077 | { |
1078 | - if (! $this->exists) { |
|
1078 | + if (!$this->exists) { |
|
1079 | 1079 | return; |
1080 | 1080 | } |
1081 | 1081 | |
@@ -1092,7 +1092,7 @@ discard block |
||
1092 | 1092 | */ |
1093 | 1093 | public function refresh() |
1094 | 1094 | { |
1095 | - if (! $this->exists) { |
|
1095 | + if (!$this->exists) { |
|
1096 | 1096 | return $this; |
1097 | 1097 | } |
1098 | 1098 | |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | $this->attributes, $except ? array_unique(array_merge($except, $defaults)) : $defaults |
1126 | 1126 | ); |
1127 | 1127 | |
1128 | - return tap(new static, function ($instance) use ($attributes) { |
|
1128 | + return tap(new static, function($instance) use ($attributes) { |
|
1129 | 1129 | $instance->setRawAttributes($attributes); |
1130 | 1130 | |
1131 | 1131 | $instance->setRelations($this->relations); |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | */ |
1141 | 1141 | public function is($model) |
1142 | 1142 | { |
1143 | - return ! is_null($model) && |
|
1143 | + return !is_null($model) && |
|
1144 | 1144 | $this->getKey() === $model->getKey() && |
1145 | 1145 | $this->getTable() === $model->getTable() && |
1146 | 1146 | $this->getConnectionName() === $model->getConnectionName(); |
@@ -1154,7 +1154,7 @@ discard block |
||
1154 | 1154 | */ |
1155 | 1155 | public function isNot($model) |
1156 | 1156 | { |
1157 | - return ! $this->is($model); |
|
1157 | + return !$this->is($model); |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | /** |
@@ -1239,7 +1239,7 @@ discard block |
||
1239 | 1239 | */ |
1240 | 1240 | public function getTable() |
1241 | 1241 | { |
1242 | - if (! isset($this->table)) { |
|
1242 | + if (!isset($this->table)) { |
|
1243 | 1243 | return str_replace( |
1244 | 1244 | '\\', '', Str::snake(Str::plural(class_basename($this))) |
1245 | 1245 | ); |
@@ -1495,7 +1495,7 @@ discard block |
||
1495 | 1495 | */ |
1496 | 1496 | public function offsetExists($offset) |
1497 | 1497 | { |
1498 | - return ! is_null($this->getAttribute($offset)); |
|
1498 | + return !is_null($this->getAttribute($offset)); |
|
1499 | 1499 | } |
1500 | 1500 | |
1501 | 1501 | /** |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public function forceFill(array $attributes) |
311 | 311 | { |
312 | - return static::unguarded(function () use ($attributes) { |
|
312 | + return static::unguarded(function () use ($attributes){ |
|
313 | 313 | return $this->fill($attributes); |
314 | 314 | }); |
315 | 315 | } |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | */ |
641 | 641 | public function saveOrFail(array $options = []) |
642 | 642 | { |
643 | - return $this->getConnection()->transaction(function () use ($options) { |
|
643 | + return $this->getConnection()->transaction(function () use ($options){ |
|
644 | 644 | return $this->save($options); |
645 | 645 | }); |
646 | 646 | } |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | $this->attributes, $except ? array_unique(array_merge($except, $defaults)) : $defaults |
1126 | 1126 | ); |
1127 | 1127 | |
1128 | - return tap(new static, function ($instance) use ($attributes) { |
|
1128 | + return tap(new static, function ($instance) use ($attributes){ |
|
1129 | 1129 | $instance->setRawAttributes($attributes); |
1130 | 1130 | |
1131 | 1131 | $instance->setRelations($this->relations); |
@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace Illuminate\Database\Eloquent\Relations; |
4 | 4 | |
5 | -use Illuminate\Database\Eloquent\Model; |
|
6 | 5 | use Illuminate\Database\Eloquent\Builder; |
7 | 6 | use Illuminate\Database\Eloquent\Collection; |
7 | +use Illuminate\Database\Eloquent\Model; |
|
8 | 8 | use Illuminate\Database\Eloquent\Relations\Concerns\SupportsDefaultModels; |
9 | 9 | |
10 | 10 | /** |
@@ -128,7 +128,7 @@ |
||
128 | 128 | // to query for via the eager loading query. We will add them to an array then |
129 | 129 | // execute a "where in" statement to gather up all of those related records. |
130 | 130 | foreach ($models as $model) { |
131 | - if (! is_null($value = $model->{$this->foreignKey})) { |
|
131 | + if (!is_null($value = $model->{$this->foreignKey})) { |
|
132 | 132 | $keys[] = $value; |
133 | 133 | } |
134 | 134 | } |
@@ -550,7 +550,7 @@ |
||
550 | 550 | /** |
551 | 551 | * Get the results of the relationship. |
552 | 552 | * |
553 | - * @return mixed |
|
553 | + * @return Collection |
|
554 | 554 | */ |
555 | 555 | public function getResults() |
556 | 556 | { |
@@ -2,12 +2,12 @@ |
||
2 | 2 | |
3 | 3 | namespace Illuminate\Database\Eloquent\Relations; |
4 | 4 | |
5 | -use Illuminate\Support\Str; |
|
6 | -use InvalidArgumentException; |
|
7 | -use Illuminate\Database\Eloquent\Model; |
|
8 | 5 | use Illuminate\Database\Eloquent\Builder; |
9 | 6 | use Illuminate\Database\Eloquent\Collection; |
7 | +use Illuminate\Database\Eloquent\Model; |
|
10 | 8 | use Illuminate\Database\Eloquent\ModelNotFoundException; |
9 | +use Illuminate\Support\Str; |
|
10 | +use InvalidArgumentException; |
|
11 | 11 | |
12 | 12 | class BelongsToMany extends Relation |
13 | 13 | { |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | if (count($result) === count(array_unique($id))) { |
511 | 511 | return $result; |
512 | 512 | } |
513 | - } elseif (! is_null($result)) { |
|
513 | + } elseif (!is_null($result)) { |
|
514 | 514 | return $result; |
515 | 515 | } |
516 | 516 | |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | */ |
541 | 541 | public function firstOrFail($columns = ['*']) |
542 | 542 | { |
543 | - if (! is_null($model = $this->first($columns))) { |
|
543 | + if (!is_null($model = $this->first($columns))) { |
|
544 | 544 | return $model; |
545 | 545 | } |
546 | 546 | |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | { |
615 | 615 | $defaults = [$this->foreignPivotKey, $this->relatedPivotKey]; |
616 | 616 | |
617 | - return collect(array_merge($defaults, $this->pivotColumns))->map(function ($column) { |
|
617 | + return collect(array_merge($defaults, $this->pivotColumns))->map(function($column){ |
|
618 | 618 | return $this->table.'.'.$column.' as pivot_'.$column; |
619 | 619 | })->unique()->all(); |
620 | 620 | } |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | { |
633 | 633 | $this->query->addSelect($this->shouldSelect($columns)); |
634 | 634 | |
635 | - return tap($this->query->paginate($perPage, $columns, $pageName, $page), function ($paginator) { |
|
635 | + return tap($this->query->paginate($perPage, $columns, $pageName, $page), function($paginator){ |
|
636 | 636 | $this->hydratePivotRelation($paginator->items()); |
637 | 637 | }); |
638 | 638 | } |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | { |
651 | 651 | $this->query->addSelect($this->shouldSelect($columns)); |
652 | 652 | |
653 | - return tap($this->query->simplePaginate($perPage, $columns, $pageName, $page), function ($paginator) { |
|
653 | + return tap($this->query->simplePaginate($perPage, $columns, $pageName, $page), function($paginator){ |
|
654 | 654 | $this->hydratePivotRelation($paginator->items()); |
655 | 655 | }); |
656 | 656 | } |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | { |
667 | 667 | $this->query->addSelect($this->shouldSelect()); |
668 | 668 | |
669 | - return $this->query->chunk($count, function ($results) use ($callback) { |
|
669 | + return $this->query->chunk($count, function($results) use ($callback) { |
|
670 | 670 | $this->hydratePivotRelation($results->all()); |
671 | 671 | |
672 | 672 | return $callback($results); |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | { |
615 | 615 | $defaults = [$this->foreignPivotKey, $this->relatedPivotKey]; |
616 | 616 | |
617 | - return collect(array_merge($defaults, $this->pivotColumns))->map(function ($column) { |
|
617 | + return collect(array_merge($defaults, $this->pivotColumns))->map(function ($column){ |
|
618 | 618 | return $this->table.'.'.$column.' as pivot_'.$column; |
619 | 619 | })->unique()->all(); |
620 | 620 | } |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | { |
633 | 633 | $this->query->addSelect($this->shouldSelect($columns)); |
634 | 634 | |
635 | - return tap($this->query->paginate($perPage, $columns, $pageName, $page), function ($paginator) { |
|
635 | + return tap($this->query->paginate($perPage, $columns, $pageName, $page), function ($paginator){ |
|
636 | 636 | $this->hydratePivotRelation($paginator->items()); |
637 | 637 | }); |
638 | 638 | } |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | { |
651 | 651 | $this->query->addSelect($this->shouldSelect($columns)); |
652 | 652 | |
653 | - return tap($this->query->simplePaginate($perPage, $columns, $pageName, $page), function ($paginator) { |
|
653 | + return tap($this->query->simplePaginate($perPage, $columns, $pageName, $page), function ($paginator){ |
|
654 | 654 | $this->hydratePivotRelation($paginator->items()); |
655 | 655 | }); |
656 | 656 | } |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | { |
667 | 667 | $this->query->addSelect($this->shouldSelect()); |
668 | 668 | |
669 | - return $this->query->chunk($count, function ($results) use ($callback) { |
|
669 | + return $this->query->chunk($count, function ($results) use ($callback){ |
|
670 | 670 | $this->hydratePivotRelation($results->all()); |
671 | 671 | |
672 | 672 | return $callback($results); |