Import multiple PHP classes or custom aliases inside Blade templates using array arguments in the @use directive.
The Blade @use directive allows importing PHP classes directly inside templates. Punyapal Shah contributed a Pull Request to Laravel expanding @use to accept array arguments.
You can import multiple classes or define custom aliases in a single directive:
{{-- Import multiple model classes --}}
@use(['App\Models\User', 'App\Models\Post'])
{{-- Import with custom aliases --}}
@use(['App\Models\User' => 'ModelUser', 'App\Models\Post' => 'ModelPost'])
{{-- Single class import still works --}}
@use('App\Models\User', 'ModelUser')
- Replaces repetitive
@php use ... @endphpblocks at the top of Blade templates - Keeps Blade template imports grouped in a clean, readable structure
- Supports alias mapping directly inside array keys and values
Related Tips
View all tips →Refresh and Pessimistically Lock Models with refreshForUpdate() in Laravel 13.27
Laravel 13.27 adds refreshForUpdate(), reloading an existing model instance in-place with fresh database attributes while acquiring an exclusive FOR UPDATE row lock.
Scope Pivot Table Queries with Closures in wherePivot() in Laravel 13.26
Laravel 13.26 allows wherePivot() and orWherePivot() to accept closures, enabling direct reuse of local scopes defined on custom Pivot models.