Skip to content

Commit 864e621

Browse files
committed
fix conflicts
2 parents 3095072 + a04b80c commit 864e621

File tree

64 files changed

+842
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+842
-96
lines changed

config/database.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
'options' => [
150150
'cluster' => env('REDIS_CLUSTER', 'redis'),
151151
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
152+
'persistent' => env('REDIS_PERSISTENT', false),
152153
],
153154

154155
'default' => [

src/Illuminate/Bus/PendingBatch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function add($jobs)
9898
protected function ensureJobIsBatchable(object|array $job): void
9999
{
100100
foreach (Arr::wrap($job) as $job) {
101-
if ($job instanceof PendingBatch) {
101+
if ($job instanceof PendingBatch || $job instanceof Closure) {
102102
return;
103103
}
104104

src/Illuminate/Collections/Arr.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,18 @@ public static function where($array, callable $callback)
930930
return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH);
931931
}
932932

933+
/**
934+
* Filter the array using the negation of the given callback.
935+
*
936+
* @param array $array
937+
* @param callable $callback
938+
* @return array
939+
*/
940+
public static function reject($array, callable $callback)
941+
{
942+
return static::where($array, fn ($value, $key) => ! $callback($value, $key));
943+
}
944+
933945
/**
934946
* Filter items where the value is not null.
935947
*

src/Illuminate/Collections/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ public function implode($value, $glue = null)
629629

630630
$first = $this->first();
631631

632-
if (is_array($first) || (is_object($first) && ! $first instanceof Stringable)) {
632+
if (is_array($first) || (is_object($first) && ! $first instanceof \Stringable)) {
633633
return implode($glue ?? '', $this->pluck($value)->all());
634634
}
635635

src/Illuminate/Database/Concerns/BuildsQueries.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
/**
2323
* @template TValue
2424
*
25-
* @mixin \Illuminate\Database\Eloquent\Builder
2625
* @mixin \Illuminate\Database\Query\Builder
2726
*/
2827
trait BuildsQueries

src/Illuminate/Database/Eloquent/Builder.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,21 @@ public function find($id, $columns = ['*'])
477477
return $this->whereKey($id)->first($columns);
478478
}
479479

480+
/**
481+
* Find a sole model by its primary key.
482+
*
483+
* @param mixed $id
484+
* @param array|string $columns
485+
* @return TModel
486+
*
487+
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException<TModel>
488+
* @throws \Illuminate\Database\MultipleRecordsFoundException
489+
*/
490+
public function findSole($id, $columns = ['*'])
491+
{
492+
return $this->whereKey($id)->sole($columns);
493+
}
494+
480495
/**
481496
* Find multiple models by their primary keys.
482497
*
@@ -1013,10 +1028,7 @@ public function paginate($perPage = null, $columns = ['*'], $pageName = 'page',
10131028

10141029
$total = value($total) ?? $this->toBase()->getCountForPagination();
10151030

1016-
$perPage = ($perPage instanceof Closure
1017-
? $perPage($total)
1018-
: $perPage
1019-
) ?: $this->model->getPerPage();
1031+
$perPage = value($perPage, $total) ?? $this->model->getPerPage();
10201032

10211033
$results = $total
10221034
? $this->forPage($page, $perPage)->get($columns)

src/Illuminate/Database/Eloquent/Collection.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,19 @@ public function contains($key, $operator = null, $value = null)
335335
return parent::contains(fn ($model) => $model->getKey() == $key);
336336
}
337337

338+
/**
339+
* Determine if a key does not exist in the collection.
340+
*
341+
* @param (callable(TModel, TKey): bool)|TModel|string|int $key
342+
* @param mixed $operator
343+
* @param mixed $value
344+
* @return bool
345+
*/
346+
public function doesntContain($key, $operator = null, $value = null)
347+
{
348+
return ! $this->contains(...func_get_args());
349+
}
350+
338351
/**
339352
* Get the array of primary keys.
340353
*

src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ public function getUpdatedAtColumn()
161161
*/
162162
public function getQualifiedCreatedAtColumn()
163163
{
164-
return $this->qualifyColumn($this->getCreatedAtColumn());
164+
$column = $this->getCreatedAtColumn();
165+
166+
return $column ? $this->qualifyColumn($column) : null;
165167
}
166168

167169
/**
@@ -171,7 +173,9 @@ public function getQualifiedCreatedAtColumn()
171173
*/
172174
public function getQualifiedUpdatedAtColumn()
173175
{
174-
return $this->qualifyColumn($this->getUpdatedAtColumn());
176+
$column = $this->getUpdatedAtColumn();
177+
178+
return $column ? $this->qualifyColumn($column) : null;
175179
}
176180

177181
/**

src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function whereHas($relation, ?Closure $callback = null, $operator = '>=',
165165
/**
166166
* Add a relationship count / exists condition to the query with where clauses.
167167
*
168-
* Also load the relationship with same condition.
168+
* Also load the relationship with the same condition.
169169
*
170170
* @param string $relation
171171
* @param (\Closure(\Illuminate\Database\Eloquent\Builder<*>|\Illuminate\Database\Eloquent\Relations\Relation<*, *, *>): mixed)|null $callback
@@ -374,7 +374,7 @@ public function whereHasMorph($relation, $types, ?Closure $callback = null, $ope
374374
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
375375
*
376376
* @param \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel, *>|string $relation
377-
* @param string|array<int, array> $types
377+
* @param string|array<int, string> $types
378378
* @param (\Closure(\Illuminate\Database\Eloquent\Builder<TRelatedModel>, string): mixed)|null $callback
379379
* @param string $operator
380380
* @param int $count
@@ -437,6 +437,25 @@ public function whereRelation($relation, $column, $operator = null, $value = nul
437437
});
438438
}
439439

440+
/**
441+
* Add a basic where clause to a relationship query and eager-load the relationship with the same conditions.
442+
*
443+
* @param \Illuminate\Database\Eloquent\Relations\Relation<*, *, *>|string $relation
444+
* @param \Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column
445+
* @param mixed $operator
446+
* @param mixed $value
447+
* @return $this
448+
*/
449+
public function withWhereRelation($relation, $column, $operator = null, $value = null)
450+
{
451+
return $this->whereRelation($relation, $column, $operator, $value)
452+
->with([
453+
$relation => fn ($query) => $column instanceof Closure
454+
? $column($query)
455+
: $query->where($column, $operator, $value),
456+
]);
457+
}
458+
440459
/**
441460
* Add an "or where" clause to a relationship query.
442461
*

src/Illuminate/Database/Eloquent/Factories/Factory.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ abstract class Factory
114114
public static $namespace = 'Database\\Factories\\';
115115

116116
/**
117-
* The default model name resolver.
117+
* The default model name resolvers.
118118
*
119-
* @var callable(self): class-string<TModel>
119+
* @var array<class-string, callable(self): class-string<TModel>>
120120
*/
121-
protected static $modelNameResolver;
121+
protected static $modelNameResolvers = [];
122122

123123
/**
124124
* The factory name resolver.
@@ -810,9 +810,9 @@ public function modelName()
810810
return $this->model;
811811
}
812812

813-
$resolver = static::$modelNameResolver ?? function (self $factory) {
813+
$resolver = static::$modelNameResolvers[static::class] ?? static::$modelNameResolvers[self::class] ?? function (self $factory) {
814814
$namespacedFactoryBasename = Str::replaceLast(
815-
'Factory', '', Str::replaceFirst(static::$namespace, '', get_class($factory))
815+
'Factory', '', Str::replaceFirst(static::$namespace, '', $factory::class)
816816
);
817817

818818
$factoryBasename = Str::replaceLast('Factory', '', class_basename($factory));
@@ -835,7 +835,7 @@ public function modelName()
835835
*/
836836
public static function guessModelNamesUsing(callable $callback)
837837
{
838-
static::$modelNameResolver = $callback;
838+
static::$modelNameResolvers[static::class] = $callback;
839839
}
840840

841841
/**
@@ -924,6 +924,18 @@ protected static function appNamespace()
924924
}
925925
}
926926

927+
/**
928+
* Flush the factory's global state.
929+
*
930+
* @return void
931+
*/
932+
public static function flushState()
933+
{
934+
static::$modelNameResolvers = [];
935+
static::$factoryNameResolver = null;
936+
static::$namespace = 'Database\\Factories\\';
937+
}
938+
927939
/**
928940
* Proxy dynamic factory methods onto their proper methods.
929941
*

0 commit comments

Comments
 (0)