News

Laravel 10.34 Released

Published
Laravel 10.34 Released image

Release updates

Never miss a Laravel release

Get an email whenever a new Laravel release lands.

This week, the Laravel team released v10.34, adding a missing() method that applies to route groups, an alias for the new Number class, an extensions validation rule, and more. Here is a bit more info about the new features introduced this week:

Allow Multiple Types in Collection's ensure() method

Ash Allen contributed an update to the Collection ensure() method that allows you to pass multiple types instead of only allowing one type:

collect([new User(), new Contact(), new Contact()])
    ->ensure([User::class, Contact::class]);

Allow missing() on Route groups

Ronald Edelschaap contributed the ability to add a missing() callback for the routes on a group:

// Before
Route::prefix('locations')
    ->group(function() {
        Route::get('{location}', [LocationsController::class, 'show'])
            ->missing(fn() => ['success' => false, 'message' => 'The requested location does not exist']);
        Route::put('{location}', [LocationsController::class, 'update'])
            ->missing(fn() => ['success' => false, 'message' => 'The requested location does not exist']);
        Route::delete('{location}', [LocationsController::class, 'destroy'])
            ->missing(fn() => ['success' => false, 'message' => 'The requested location does not exist']);
    });

// After
Route::prefix('locations')
    ->missing(fn() => ['success' => false, 'message' => 'The requested location does not exist'])
    ->group(function() {
        Route::get('{location}', [LocationsController::class, 'show']);
        Route::put('{location}', [LocationsController::class, 'update']);
        Route::delete('{location}', [LocationsController::class, 'destroy']);
    });

Extensions validation rule

@eusonlito contributed a file extensions validation rule that you can use in combination with the mimes validation rule:

['file', 'mimes:jpg,jpeg,png', 'extensions:jpg,png']

The extensions rule was added to the Validation documentation, which notes that the extensions rule should be used in tandem with validating the mime type via the mimes rule.

See Pull Request #49082 for more details.

Alias Number class

Jamie York contributed aliasing the Number Utility Class for quick use in Blade templates without needing to import the full namespace:

<p>Percentage: {{ Number::percentage(50) }}</p>

Conditionable added to TestResponse

Noboru Shiroiwa contributed adding the Conditionable trait to the TestResponse class, which you can use when asserting the response:

test('name', function ($attributes) {
    $user = User::factory()->create($attributes);

    $response = $this
        ->actingAs($user)
        ->get('/');

    $response
        ->assertOk()
        ->when($attributes['gender'] === 1, fn () => $response->assertSee('Hello boys!'))
        ->when($attributes['gender'] === 2, fn () => $response->assertSee('Hello girls!'));
})->with([
    'boy' => [
        [
            'name' => 'Michael',
            'gender' => 1,
        ],
    ],
    'girl' => [
        [
            'name' => 'Susan',
            'gender' => 2,
        ],
    ],
]);

Release notes

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

v10.34.0

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
pgjumbo: A PostgreSQL Client for macOS, Windows, and Linux image

pgjumbo: A PostgreSQL Client for macOS, Windows, and Linux

Read article
Laranon: Reversible PII Anonymization for Laravel and LLMs image

Laranon: Reversible PII Anonymization for Laravel and LLMs

Read article
PHP 8.6 is released!  image

PHP 8.6 is released!

Read article
Laravel Warrant: Row-Level Permissions With Eloquent image

Laravel Warrant: Row-Level Permissions With Eloquent

Read article
JSON Schema Validation Rules and a RetryFor Attribute in Laravel 13.43 image

JSON Schema Validation Rules and a RetryFor Attribute in Laravel 13.43

Read article
Durable Workflow: Long-Running Workflows for Laravel image

Durable Workflow: Long-Running Workflows for Laravel

Read article