Never Miss a Laravel Release 🚀
The Laravel team released v12.2.0, including a ddBody() test response method, support for a singular model through a HasManyThrough, increment, decrement context keys, and more.
In addition to the v12.2.0 release, the Laravel Installer now supports community starter kits. Tony Messias contributed this installer feature, making installing starter kits easier using the familiar laravel new command.
Community Starter Kit Support in laravel new
In addition to installing a new project with one of the official Laravel Starter Kits, the laravel new command supports using a community starter kit:
laravel new --using statamic/statamic my-statamic-applaravel new --using tnylea/filamentapp my-filament-app
If you'd like to see what community starter kits are available, Tony Lea created tnylea/laravel-new, which contains a list of projects and/or starter kits that can be installed using the Laravel installer. It is important to do your homework on community starter kits and learn about their source code.
TestResponse ddBody() Method
Sam Carré contributed a ddBody() method to the TestResponse class as a convenience to dumping the contents of the response:
// In a feature test...$response = $this->get('/example');$response->ddBody(); // Dumps the whole body// Dump a specific JSON key$response->ddBody('title'); // Uses $this->ddJson('title') under the hood
Add CanBeOneOfMany Support to HasOneThrough
Caleb White contributed CanBeOneOfMany support to the HasOneThrough relationship. You can retrieve a singular model from a larger HasManyThrough relationship:
namespace App\Models; use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\Relations\HasOneThrough; class Application extends Model{ /** * Get the latest deployment for the application. */ public function latestDeployment(): HasOneThrough { return $this->deployments()->one()->latestOfMany(); }}
Context Increment and Decrement Methods
@mattmcdev contributed increment and decrement methods to Context. This simplifies keeping track of a counter (i.e., number of requests made), etc.:
Context::increment('uploads'); // 1Context::increment('uploads'); // 2Context::increment('uploads', 5); // 7
Release notes
You can see the complete list of new features and updates below and the diff between 12.1.0 and 12.2.0 on GitHub. The following release notes are directly from the changelog:
v12.2.0
- Add dates to allowed PHPDoc types of Builder::having() by @miken32 in https://github.com/laravel/framework/pull/54899
- [11.x] Fix double negative in
whereNotMorphedTo()query by @owenvoke in https://github.com/laravel/framework/pull/54902 - Add test for Arr::partition by @liamduckett in https://github.com/laravel/framework/pull/54913
- [11.x] Expose process checkTimeout method by @mattmcdev in https://github.com/laravel/framework/pull/54912
- [12.x] Compilable for Validation Contract by @peterfox in https://github.com/laravel/framework/pull/54882
- [11.x] Backport "Change
paginate()method return types to\Illuminate\Pagination\LengthAwarePaginator" by @carestad in https://github.com/laravel/framework/pull/54917 - [11.x] Revert faulty change to
EnumeratesValues::ensure()doc block by @axlon in https://github.com/laravel/framework/pull/54919 - Ensure ValidationEmailRuleTest skips tests requiring the intl extension when unavailable by @alikhosravidev in https://github.com/laravel/framework/pull/54918
- ✅ Ensure Enum validation is case-sensitive by adding a new test case. by @alikhosravidev in https://github.com/laravel/framework/pull/54922
- [12.x] Feature: Collection chunk without preserving keys by @liamduckett in https://github.com/laravel/framework/pull/54916
- [12.x] Add test coverage for Uri::withQueryIfMissing method by @mohammadrasoulasghari in https://github.com/laravel/framework/pull/54923
- Fix issue with using RedisCluster with compression or serialization by @rzv-me in https://github.com/laravel/framework/pull/54934
- [12.x] Add test coverage for Str::replaceMatches method by @mohammadrasoulasghari in https://github.com/laravel/framework/pull/54930
- [12.x] Types: Collection chunk without preserving keys by @liamduckett in https://github.com/laravel/framework/pull/54924
- [12.x] Add
ddBodymethod to TestResponse for dumping various response payloads by @Sammyjo20 in https://github.com/laravel/framework/pull/54933 - [11.x] Backport "Fix issue with using
RedisClusterwith compression or serialization" by @rzv-me in https://github.com/laravel/framework/pull/54935 - [12.x] feat: add
CanBeOneOfManysupport toHasOneThroughby @calebdw in https://github.com/laravel/framework/pull/54759 - [12.x] Hotfix - Add function_exists check to ddBody in TestResponse by @Sammyjo20 in https://github.com/laravel/framework/pull/54937
- [12.x] Refactor: Remove unnecessary variables in Str class methods by @mohammadrasoulasghari in https://github.com/laravel/framework/pull/54963
- Add Tests for Str::pluralPascal Method by @mohammadrasoulasghari in https://github.com/laravel/framework/pull/54957
- [12.x] Fix visibility of setUp and tearDown in tests by @naopusyu in https://github.com/laravel/framework/pull/54950
- [12.x] Test Improvements by @crynobone in https://github.com/laravel/framework/pull/54944
- Fix missing return in
assertOnlyInvalidby @parth391 in https://github.com/laravel/framework/pull/54941 - Handle case when migrate:install command is called and table exists by @joe-tito in https://github.com/laravel/framework/pull/54938
- [11.x] Fix callOnce in Seeder so it handles arrays properly by @lbovit in https://github.com/laravel/framework/pull/54985
- Change "exceptoin" spelling mistake to "exception" by @hvlucas in https://github.com/laravel/framework/pull/54979
- [12.x] Add test for after method in LazyCollection by @mohammadrasoulasghari in https://github.com/laravel/framework/pull/54978
- [12.x] Add
incrementanddecrementmethods toContextby @mattmcdev in https://github.com/laravel/framework/pull/54976 - Ensure ExcludeIf correctly rejects a null value as an invalid condition by @alikhosravidev in https://github.com/laravel/framework/pull/54973
- [12.x] apply Pint rule "no_spaces_around_offset" by @browner12 in https://github.com/laravel/framework/pull/54970
- [12.x] apply Pint rule "single_line_comment_style" by @browner12 in https://github.com/laravel/framework/pull/54969
- [12.x] do not use mix of newline and inline formatting by @browner12 in https://github.com/laravel/framework/pull/54967
- [12.x] use single indent for multiline ternaries by @browner12 in https://github.com/laravel/framework/pull/54971