Back to Blog

Laravel 10.35 Released

Julian Beaujardin
Julian Beaujardin Reference: Laravel News December 6th, 2023

The Laravel team released v10.35 with a Blade @use directive, a number abbreviation helper, the ability to generate a secret with artisan down, and more. Here is a bit more info about the new features introduced this week:

Add a Blade @use() directive

Simon Hamp contributed a @use() directive to import a PHP class into a Blade template without using raw PHP tags:

{{-- Before --}}
@php
use \App\Enums\WidgetStatusEnum as Status;
@endphp

{{-- After --}}
@use('App\Enums\WidgetStatusEnum', 'Status')
@use('App\Models\Bar')

{{ Status::Foo }}
{{ Bar::first() }}

Abbreviate a number with the Number::abbreviate() method

@jcsoriano contributed a Number::abbreviate() class to the newly added Number Class, which provides a human-readable abbreviated number:

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"

Add the --with-secret option to the artisan down command

Jacob Daniel Prunkl contributed a --with-secret option to the artisan down command that will generate a secret phrase that can be used to bypass maintenance mode so the user doesn't have to define one themselves:

Add Conditionable trait to the AssertableJson class

Khalil Laleh contributed adding the Conditionable trait to the AssertableJson class, to make it possible to assert based on a given conditional:

// 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'))
    // ...
;

Release notes

You can see the complete list of new features and updates below and the diff between 10.34.0 and 10.35.0 on GitHub. The following release notes are directly from the changelog