Skip to content

Commit 6c26422

Browse files
committed
Merge tag 'v12.7.2'
Signed-off-by: Mior Muhammad Zaki <[email protected]>
2 parents 780533b + a4ba76e commit 6c26422

File tree

82 files changed

+2675
-230
lines changed

Some content is hidden

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

82 files changed

+2675
-230
lines changed

CHANGELOG.md

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,91 @@
11
# Release Notes for 12.x
22

3-
## [Unreleased](https://github.com/laravel/framework/compare/v12.3.0...12.x)
3+
## [Unreleased](https://github.com/laravel/framework/compare/v12.7.1...12.x)
4+
5+
## [v12.7.1](https://github.com/laravel/framework/compare/v12.7.0...v12.7.1) - 2025-04-03
6+
7+
## [v12.7.0](https://github.com/laravel/framework/compare/v12.6.0...v12.7.0) - 2025-04-03
8+
9+
* [12.x] `AbstractPaginator` should implement `CanBeEscapedWhenCastToString` by [@gdebrauwer](https://github.com/gdebrauwer) in https://github.com/laravel/framework/pull/55256
10+
* [12.x] Add `whereAttachedTo()` Eloquent builder method by [@bakerkretzmar](https://github.com/bakerkretzmar) in https://github.com/laravel/framework/pull/55245
11+
* Make Illuminate\Support\Uri Macroable by [@riesjart](https://github.com/riesjart) in https://github.com/laravel/framework/pull/55260
12+
* [12.x] Add resource helper functions to Model/Collections by [@TimKunze96](https://github.com/TimKunze96) in https://github.com/laravel/framework/pull/55107
13+
* [12.x]: Use char(36) for uuid type on MariaDB < 10.7.0 by [@boedah](https://github.com/boedah) in https://github.com/laravel/framework/pull/55197
14+
* [12.x] Introducing `toArray` to `ComponentAttributeBag` class by [@devajmeireles](https://github.com/devajmeireles) in https://github.com/laravel/framework/pull/55258
15+
16+
## [v12.6.0](https://github.com/laravel/framework/compare/v12.5.0...v12.6.0) - 2025-04-02
17+
18+
* [12.x] Dont stop pruning if pruning one model fails by [@gdebrauwer](https://github.com/gdebrauwer) in https://github.com/laravel/framework/pull/55237
19+
* [12.x] Update Date Facade Docblocks by [@fdalcin](https://github.com/fdalcin) in https://github.com/laravel/framework/pull/55235
20+
* Make `db:seed` command prohibitable by [@spawnia](https://github.com/spawnia) in https://github.com/laravel/framework/pull/55238
21+
* [12.x] Introducing `Rules\Password::appliedRules` Method by [@devajmeireles](https://github.com/devajmeireles) in https://github.com/laravel/framework/pull/55206
22+
* [12.x] Allowing merging model attributes before insert via `Model::fillAndInsert()` by [@cosmastech](https://github.com/cosmastech) in https://github.com/laravel/framework/pull/55038
23+
* [12.x] Fix type hints for DateTimeZone and DateTimeInterface on DateFactory by [@AndrewMast](https://github.com/AndrewMast) in https://github.com/laravel/framework/pull/55243
24+
* [12.x] Fix DateFactory docblock type hints by [@AndrewMast](https://github.com/AndrewMast) in https://github.com/laravel/framework/pull/55244
25+
* List missing `migrate:rollback` in DB::prohibitDestructiveCommands PhpDoc by [@spawnia](https://github.com/spawnia) in https://github.com/laravel/framework/pull/55252
26+
* [12.x] Add `Http::requestException()` by [@cosmastech](https://github.com/cosmastech) in https://github.com/laravel/framework/pull/55241
27+
* New: Uri `pathSegments()` helper method by [@chester-sykes](https://github.com/chester-sykes) in https://github.com/laravel/framework/pull/55250
28+
* [12.x] Do not require returning a Builder instance from a local scope method by [@cosmastech](https://github.com/cosmastech) in https://github.com/laravel/framework/pull/55246
29+
30+
## [v12.5.0](https://github.com/laravel/framework/compare/v12.4.1...v12.5.0) - 2025-04-01
31+
32+
* Correct misspellings by [@szepeviktor](https://github.com/szepeviktor) in https://github.com/laravel/framework/pull/55218
33+
* [12.x] Add ability to flush state on Vite helper by [@timacdonald](https://github.com/timacdonald) in https://github.com/laravel/framework/pull/55228
34+
* [12.x] Support taggeable store flushed cache events by [@erikn69](https://github.com/erikn69) in https://github.com/laravel/framework/pull/55223
35+
* Revert "[12.x] Support taggeable store flushed cache events" by [@taylorotwell](https://github.com/taylorotwell) in https://github.com/laravel/framework/pull/55232
36+
* [12.x] Allow configuration of retry period for RoundRobin and Failover mail transports by [@jnoordsij](https://github.com/jnoordsij) in https://github.com/laravel/framework/pull/55222
37+
* [12.x] Add --json option to EventListCommand by [@hotsaucejake](https://github.com/hotsaucejake) in https://github.com/laravel/framework/pull/55207
38+
39+
## [v12.4.1](https://github.com/laravel/framework/compare/v12.4.0...v12.4.1) - 2025-03-30
40+
41+
* [12.x] Add `Expression` type to param `$value` of `QueryBuilder` `orHaving()` method by [@faissaloux](https://github.com/faissaloux) in https://github.com/laravel/framework/pull/55202
42+
* [12.x] Fix URL generation with optional parameters (regression in #54811) by [@stancl](https://github.com/stancl) in https://github.com/laravel/framework/pull/55213
43+
* [12.x] Fix failing tests on windows OS by [@imanghafoori1](https://github.com/imanghafoori1) in https://github.com/laravel/framework/pull/55210
44+
45+
## [v12.4.0](https://github.com/laravel/framework/compare/v12.3.0...v12.4.0) - 2025-03-29
46+
47+
* [12.x] Reset PHP’s peak memory usage when resetting scope for queue worker by [@TimWolla](https://github.com/TimWolla) in https://github.com/laravel/framework/pull/55069
48+
* [12.x] Add `AsHtmlString` cast by [@ralphjsmit](https://github.com/ralphjsmit) in https://github.com/laravel/framework/pull/55071
49+
* [12.x] Add `Arr::sole()` method by [@ralphjsmit](https://github.com/ralphjsmit) in https://github.com/laravel/framework/pull/55070
50+
* Improve warning message in `ApiInstallCommand` by [@sajjadhossainshohag](https://github.com/sajjadhossainshohag) in https://github.com/laravel/framework/pull/55081
51+
* [12.x] use already determined `related` property by [@browner12](https://github.com/browner12) in https://github.com/laravel/framework/pull/55075
52+
* [12.x] use "class-string" where appropriate in relations by [@browner12](https://github.com/browner12) in https://github.com/laravel/framework/pull/55074
53+
* [12.x] `QueueFake::listenersPushed()` by [@cosmastech](https://github.com/cosmastech) in https://github.com/laravel/framework/pull/55063
54+
* [12.x] Added except() method to Model class for excluding attributes by [@vishal2931](https://github.com/vishal2931) in https://github.com/laravel/framework/pull/55072
55+
* [12.x] fix: add TPivotModel default and define pivot property in {Belongs,Morph}ToMany by [@calebdw](https://github.com/calebdw) in https://github.com/laravel/framework/pull/55086
56+
* [12.x] remove `@return` docblocks on constructors by [@browner12](https://github.com/browner12) in https://github.com/laravel/framework/pull/55076
57+
* [12.x] Add NamedScope attribute by [@shaedrich](https://github.com/shaedrich) in https://github.com/laravel/framework/pull/54450
58+
* [12.x] Improve syntax highlighting for stub type files by [@kayw-geek](https://github.com/kayw-geek) in https://github.com/laravel/framework/pull/55094
59+
* [12.x] Prefer `new Collection` over `Collection::make` by [@AhmedAlaa4611](https://github.com/AhmedAlaa4611) in https://github.com/laravel/framework/pull/55091
60+
* [12.x] Fix except() method to support casted values by [@vishal2931](https://github.com/vishal2931) in https://github.com/laravel/framework/pull/55124
61+
* [12.x] Add testcase for findSole method by [@mrvipchien](https://github.com/mrvipchien) in https://github.com/laravel/framework/pull/55115
62+
* [12.x] Types: PasswordBroker::reset by [@liamduckett](https://github.com/liamduckett) in https://github.com/laravel/framework/pull/55109
63+
* [12.x] assertThrowsNothing by [@gdebrauwer](https://github.com/gdebrauwer) in https://github.com/laravel/framework/pull/55100
64+
* [12.x] Fix type nullability on PasswordBroker.events property by [@jnoordsij](https://github.com/jnoordsij) in https://github.com/laravel/framework/pull/55097
65+
* [12.x] Fix return type annotation in decrementPendingJobs method by [@shane-zeng](https://github.com/shane-zeng) in https://github.com/laravel/framework/pull/55133
66+
* [12.x] Fix return type annotation in compile method by [@shane-zeng](https://github.com/shane-zeng) in https://github.com/laravel/framework/pull/55132
67+
* [12.x] feat: Add `whereNull` and `whereNotNull` to `Assertablejson` by [@faissaloux](https://github.com/faissaloux) in https://github.com/laravel/framework/pull/55131
68+
* [12.x] fix: use contextual bindings in class dependency resolution by [@calebdw](https://github.com/calebdw) in https://github.com/laravel/framework/pull/55090
69+
* Better return types for `Illuminate\Queue\Jobs\Job::getJobId()` and `Illuminate\Queue\Jobs\DatabaseJob::getJobId()` methods by [@petrknap](https://github.com/petrknap) in https://github.com/laravel/framework/pull/55138
70+
* Remove remaining [@return](https://github.com/return) tags from constructors by [@mohammadrasoulasghari](https://github.com/mohammadrasoulasghari) in https://github.com/laravel/framework/pull/55136
71+
* [12.x] Various URL generation bugfixes by [@stancl](https://github.com/stancl) in https://github.com/laravel/framework/pull/54811
72+
* Add an optional `shouldRun` method to migrations. by [@danmatthews](https://github.com/danmatthews) in https://github.com/laravel/framework/pull/55011
73+
* [12.x] `Uri` prevent empty query string by [@rojtjo](https://github.com/rojtjo) in https://github.com/laravel/framework/pull/55146
74+
* [12.x] Only call the ob_flush function if there is active buffer in eventStream by [@tonysm](https://github.com/tonysm) in https://github.com/laravel/framework/pull/55141
75+
* [12.x] Add CacheFlushed Event by [@tech-wolf-tw](https://github.com/tech-wolf-tw) in https://github.com/laravel/framework/pull/55142
76+
* [12.x] Update DateFactory method annotations for Carbon v3 compatibility by [@kayw-geek](https://github.com/kayw-geek) in https://github.com/laravel/framework/pull/55151
77+
* [12.x] Improve docblocks for file related methods of InteractsWithInput by [@SanderMuller](https://github.com/SanderMuller) in https://github.com/laravel/framework/pull/55156
78+
* [12.x] Enhance `FileViewFinder` doc-blocks by [@imanghafoori1](https://github.com/imanghafoori1) in https://github.com/laravel/framework/pull/55183
79+
* Support using null-safe operator with `null` value by [@willrowe](https://github.com/willrowe) in https://github.com/laravel/framework/pull/55175
80+
* [12.x] Fix: Make Paginated Queries Consistent Across Pages by [@tomchkk](https://github.com/tomchkk) in https://github.com/laravel/framework/pull/55176
81+
* [12.x] Add `pipe` method query builders by [@timacdonald](https://github.com/timacdonald) in https://github.com/laravel/framework/pull/55171
82+
* [12.x] fix: one of many subquery constraints by [@calebdw](https://github.com/calebdw) in https://github.com/laravel/framework/pull/55168
83+
* [12.x] fix(postgres): missing parentheses in whereDate/whereTime for json columns by [@saibotk](https://github.com/saibotk) in https://github.com/laravel/framework/pull/55159
84+
* Fix factory creation through attributes by [@davidstoker](https://github.com/davidstoker) in https://github.com/laravel/framework/pull/55190
85+
* [12.x] Fix Concurrency::run to preserve callback result order by [@chaker2710](https://github.com/chaker2710) in https://github.com/laravel/framework/pull/55161
86+
* [12.x] Log: Add optional keys parameter to `Log::withoutContext` to remove selected context from future logs by [@mattroylloyd](https://github.com/mattroylloyd) in https://github.com/laravel/framework/pull/55181
87+
* [12.x] Add `Expression` type to param `$value` of `QueryBuilder` `having()` method by [@faissaloux](https://github.com/faissaloux) in https://github.com/laravel/framework/pull/55200
88+
* [12.x] Add flag to disable where clauses for `withAttributes` method on Eloquent Builder by [@AndrewMast](https://github.com/AndrewMast) in https://github.com/laravel/framework/pull/55199
489

590
## [v12.3.0](https://github.com/laravel/framework/compare/v12.2.0...v12.3.0) - 2025-03-18
691

config/mail.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
'smtp',
8686
'log',
8787
],
88+
'retry_after' => 60,
8889
],
8990

9091
'roundrobin' => [
@@ -93,6 +94,7 @@
9394
'ses',
9495
'postmark',
9596
],
97+
'retry_after' => 60,
9698
],
9799

98100
],

src/Illuminate/Collections/Collection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Contracts\Support\CanBeEscapedWhenCastToString;
88
use Illuminate\Support\Traits\EnumeratesValues;
99
use Illuminate\Support\Traits\Macroable;
10+
use Illuminate\Support\Traits\TransformsToResourceCollection;
1011
use InvalidArgumentException;
1112
use stdClass;
1213
use Traversable;
@@ -24,7 +25,7 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl
2425
/**
2526
* @use \Illuminate\Support\Traits\EnumeratesValues<TKey, TValue>
2627
*/
27-
use EnumeratesValues, Macroable;
28+
use EnumeratesValues, Macroable, TransformsToResourceCollection;
2829

2930
/**
3031
* The items contained in the collection.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace Illuminate\Support\Traits;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
use Illuminate\Http\Resources\Json\JsonResource;
7+
use Illuminate\Http\Resources\Json\ResourceCollection;
8+
use LogicException;
9+
10+
trait TransformsToResourceCollection
11+
{
12+
/**
13+
* Create a new resource collection instance for the given resource.
14+
*
15+
* @param class-string<JsonResource>|null $resourceClass
16+
* @return ResourceCollection
17+
*
18+
* @throws \Throwable
19+
*/
20+
public function toResourceCollection(?string $resourceClass = null): ResourceCollection
21+
{
22+
if ($resourceClass === null) {
23+
return $this->guessResourceCollection();
24+
}
25+
26+
return $resourceClass::collection($this);
27+
}
28+
29+
/**
30+
* Guess the resource collection for the items.
31+
*
32+
* @return ResourceCollection
33+
*
34+
* @throws \Throwable
35+
*/
36+
protected function guessResourceCollection(): ResourceCollection
37+
{
38+
if ($this->isEmpty()) {
39+
return new ResourceCollection($this);
40+
}
41+
42+
$model = $this->items[0] ?? null;
43+
44+
throw_unless(is_object($model), LogicException::class, 'Resource collection guesser expects the collection to contain objects.');
45+
46+
/** @var class-string<Model> $className */
47+
$className = get_class($model);
48+
49+
throw_unless(method_exists($className, 'guessResourceName'), LogicException::class, sprintf('Expected class %s to implement guessResourceName method. Make sure the model uses the TransformsToResource trait.', $className));
50+
51+
foreach ($className::guessResourceName() as $resourceClass) {
52+
if (is_string($resourceClass) && class_exists($resourceClass)) {
53+
return $resourceClass::collection($this);
54+
}
55+
}
56+
57+
throw new LogicException(sprintf('Failed to find resource class for model [%s].', $className));
58+
}
59+
}

src/Illuminate/Concurrency/ForkDriver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public function run(Closure|array $tasks): array
2525
/** @phpstan-ignore class.notFound */
2626
$results = Fork::new()->run(...$values);
2727

28+
ksort($results);
29+
2830
return array_combine($keys, $results);
2931
}
3032

src/Illuminate/Database/Concerns/BuildsQueries.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ protected function cursorPaginator($items, $perPage, $cursor, $options)
587587
}
588588

589589
/**
590-
* Pass the query to a given callback.
590+
* Pass the query to a given callback and then return it.
591591
*
592592
* @param callable($this): mixed $callback
593593
* @return $this
@@ -598,4 +598,17 @@ public function tap($callback)
598598

599599
return $this;
600600
}
601+
602+
/**
603+
* Pass the query to a given callback and return the result.
604+
*
605+
* @template TReturn
606+
*
607+
* @param (callable($this): TReturn) $callback
608+
* @return (TReturn is null|void ? $this : TReturn)
609+
*/
610+
public function pipe($callback)
611+
{
612+
return $callback($this) ?? $this;
613+
}
601614
}

src/Illuminate/Database/Console/Seeds/SeedCommand.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Console\Command;
66
use Illuminate\Console\ConfirmableTrait;
7+
use Illuminate\Console\Prohibitable;
78
use Illuminate\Database\ConnectionResolverInterface as Resolver;
89
use Illuminate\Database\Eloquent\Model;
910
use Symfony\Component\Console\Attribute\AsCommand;
@@ -13,7 +14,7 @@
1314
#[AsCommand(name: 'db:seed')]
1415
class SeedCommand extends Command
1516
{
16-
use ConfirmableTrait;
17+
use ConfirmableTrait, Prohibitable;
1718

1819
/**
1920
* The console command name.
@@ -55,8 +56,9 @@ public function __construct(Resolver $resolver)
5556
*/
5657
public function handle()
5758
{
58-
if (! $this->confirmToProceed()) {
59-
return 1;
59+
if ($this->isProhibited() ||
60+
! $this->confirmToProceed()) {
61+
return Command::FAILURE;
6062
}
6163

6264
$this->components->info('Seeding database.');

src/Illuminate/Database/Eloquent/Attributes/Scope.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ class Scope
99
{
1010
/**
1111
* Create a new attribute instance.
12-
*
13-
* @param array|string $classes
14-
* @return void
1512
*/
1613
public function __construct()
1714
{

src/Illuminate/Database/Eloquent/Builder.php

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,67 @@ public function hydrate(array $items)
449449
}, $items));
450450
}
451451

452+
/**
453+
* Insert into the database after merging the model's default attributes, setting timestamps, and casting values.
454+
*
455+
* @param array<int, array<string, mixed>> $values
456+
* @return bool
457+
*/
458+
public function fillAndInsert(array $values)
459+
{
460+
return $this->insert($this->fillForInsert($values));
461+
}
462+
463+
/**
464+
* Insert (ignoring errors) into the database after merging the model's default attributes, setting timestamps, and casting values.
465+
*
466+
* @param array<int, array<string, mixed>> $values
467+
* @return int
468+
*/
469+
public function fillAndInsertOrIgnore(array $values)
470+
{
471+
return $this->insertOrIgnore($this->fillForInsert($values));
472+
}
473+
474+
/**
475+
* Insert a record into the database and get its ID after merging the model's default attributes, setting timestamps, and casting values.
476+
*
477+
* @param array<string, mixed> $values
478+
* @return int
479+
*/
480+
public function fillAndInsertGetId(array $values)
481+
{
482+
return $this->insertGetId($this->fillForInsert([$values])[0]);
483+
}
484+
485+
/**
486+
* Enrich the given values by merging in the model's default attributes, adding timestamps, and casting values.
487+
*
488+
* @param array<int, array<string, mixed>> $values
489+
* @return array<int, array<string, mixed>>
490+
*/
491+
public function fillForInsert(array $values)
492+
{
493+
if (empty($values)) {
494+
return [];
495+
}
496+
497+
if (! is_array(reset($values))) {
498+
$values = [$values];
499+
}
500+
501+
$this->model->unguarded(function () use (&$values) {
502+
foreach ($values as $key => $rowValues) {
503+
$values[$key] = tap(
504+
$this->newModelInstance($rowValues),
505+
fn ($model) => $model->setUniqueIds()
506+
)->getAttributes();
507+
}
508+
});
509+
510+
return $this->addTimestampsToUpsertValues($values);
511+
}
512+
452513
/**
453514
* Create a collection of models from a raw query.
454515
*
@@ -1822,16 +1883,19 @@ protected function addNestedWiths($name, $results)
18221883
*
18231884
* @param \Illuminate\Contracts\Database\Query\Expression|array|string $attributes
18241885
* @param mixed $value
1886+
* @param bool $asConditions
18251887
* @return $this
18261888
*/
1827-
public function withAttributes(Expression|array|string $attributes, $value = null)
1889+
public function withAttributes(Expression|array|string $attributes, $value = null, $asConditions = true)
18281890
{
18291891
if (! is_array($attributes)) {
18301892
$attributes = [$attributes => $value];
18311893
}
18321894

1833-
foreach ($attributes as $column => $value) {
1834-
$this->where($this->qualifyColumn($column), $value);
1895+
if ($asConditions) {
1896+
foreach ($attributes as $column => $value) {
1897+
$this->where($this->qualifyColumn($column), $value);
1898+
}
18351899
}
18361900

18371901
$this->pendingAttributes = array_merge($this->pendingAttributes, $attributes);

0 commit comments

Comments
 (0)