Laravel 10.35 Released
The Laravel team rolled out version 10.35, featuring a Blade @use directive, a number abbreviation helper, and the ability to create a secret using artisan down, among other additions. Here are further details on the updates introduced this week:
Blade @use() directive addition:
{{-- Before --}}
@php
use \App\Enums\WidgetStatusEnum as Status;
@endphp
{{-- After --}}
@use('App\Enums\WidgetStatusEnum', 'Status')
@use('App\Models\Bar')
{{ Status::Foo }}
{{ Bar::first() }}
Simon Hamp's contribution includes a @use() directive, enabling the import of a PHP class into a Blade template without relying on raw PHP tags.
Number abbreviation via Number::abbreviate():
@jcsoriano contributed the Number::abbreviate() class to the newly incorporated Number Class. This class facilitates the creation of human-readable abbreviated numbers.
Number::abbreviate(1_000_000); // "1M"
Number::abbreviate(100_001); // "100K"
Number::abbreviate(100_100); // "100K"
Number::abbreviate(99_999); // "100K"
Number::abbreviate(99_499); // "99K"
--with-secret option in the artisan down command:
Jacob Daniel contribution is the --with-secret option in the artisan down command. This option generates a secret phrase, allowing bypassing of maintenance mode without user-defined input.
Conditionable trait addition to the AssertableJson class:
Khalil Laleh's addition involves the integration of the Conditionable trait into the AssertableJson class. This trait enables assertions based on specific conditions, streamlining the assertion process within the class.
// Before
$response->assertJson(function (AssertableJson $json) use ($condition) {
$json->has('data');
if ($condition) {
$json->has('meta');
}
$json->etc();
});
// After
$response
->assertJson(fn (AssertableJson $json) => $json->has('data'))
->when($condition, fn (AssertableJson $json) => $json->has('meta'))
// ...
;
These are the updates made to Laravel web development. If you need quality services to create an effective, modern, advanced online shop leave your requests. Laravel web development from Devnrise team allows you to solve business problems on the web. We create large portals, develop and promote them.