Laravel 10.22 Released
Published on by Paul Redmond
This week, the Laravel team released v10.21.1 and v10.22 with ULID testing helpers, precognition testing helpers, Enum support in Rule::in()
and Rule::notIn()
validation rules, and more:
ULID testing helpers
Jason Jones contributed testing helpers for the generation of ULIDs to match testing helpers created for UUIDs:
$ulid = Str::ulid();Str::createUlidsUsing(fn() => $ulid);Str::ulid() === $ulid; // true // Freeze ULID generation then restore generation$ulid = Str::freezeUlids();Str::ulid() === Str::ulid() === $ulid; // trueStr::createUlidsNormally(); // Freeze for the duration of the closureStr::freezeUlids(function ($ulid) { Str::ulid() === Str::ulid() === $ulid; // true}); Str::ulid() === Str::ulid(); // false // Sequences of ULIDsStr::createUlidsUsingSequence([ $zeroth = Str::ulid(), $first = Str::ulid(),]); Str::ulid() === $zeroth;Str::ulid() === $first;Str::ulid(); // back to normally generated ULIDs.
I didn't list the entire API available; you can check out Pull Request #48276 for more details.
Precognition testing helpers
Peter Fox contributed testing helpers for Laravel Precognition
$this->withPrecognition() ->get('/') ->assertSuccessfulPrecognition();
Enum support for in and notIn validation rules
Tim Geisendoerfer contributed enum support for the Rule::in()
and Rule::notIn()
validation rules:
enum Color: string{ case RED = 'red'; case GREEN = 'green'; case BLUE = 'blue';} // Use the Color enum with Rule::in()Validator::validate( ['color'=>'green'], [ 'color'=> [ Rule::in([Color::RED, Color::GREEN]) ] ],);
Release notes
You can see the complete list of new features and updates below and the diff between 10.21.0 and 10.22.0 on GitHub. The following release notes are directly from the changelog:
v10.22.0 - 2023-09-05
- [10.x] Add ulid testing helpers by @Jasonej in https://github.com/laravel/framework/pull/48276
- [10.x] Fix issue with table prefix duplication in DatabaseTruncation trait by @mobidev86 in https://github.com/laravel/framework/pull/48291
- [10.x] Fixed a typo in phpdoc block by @back2Lobby in https://github.com/laravel/framework/pull/48296
v10.21.1 - 2023-09-04
- [10.x] HotFix: throw captured
UniqueConstraintViolationException
if there are no matching records onSELECT
retry by @mpyw in https://github.com/laravel/framework/pull/48234 - [10.x] Adds testing helpers for Precognition by @peterfox in https://github.com/laravel/framework/pull/48151
- [10.x] GeneratorCommand - Sorting possible models and events by @TWithers in https://github.com/laravel/framework/pull/48249
- [10.x] Add Enum Support to the In and NotIn Validation Rules by @geisi in https://github.com/laravel/framework/pull/48247
- PHP 8.3 Support by @driesvints in https://github.com/laravel/framework/pull/48265
- [10.x] Call
renderForAssertions
in all Mailable assertions by @jamsch in https://github.com/laravel/framework/pull/48254 - [10.x] Introduce
requireEnv
helper by @lucasmichot in https://github.com/laravel/framework/pull/48261 - [10.x] Combine prefix with table for
compileDropPrimary
PostgreSQL by @dyriavin in https://github.com/laravel/framework/pull/48268 - [10.x] BelongsToMany Docblock Improvements by @crynobone in https://github.com/laravel/framework/pull/48282