Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Add support for array-based use statements in Blade templates #49481

Closed
wants to merge 1 commit into from
Closed

[10.x] Add support for array-based use statements in Blade templates #49481

wants to merge 1 commit into from

Conversation

MrPunyapal
Copy link
Contributor

Add support for array-based use statements in Blade templates

This PR adds support for array-based use statements in Blade templates. This is useful when you want to use multiple classes from the same namespace.

usage example

@use(['App\Models\User', 'App\Models\Post'])

// is equivalent to

<?php use \App\Models\User; use \App\Models\Post; ?>

// and

@use(['App\Models\User' =>'ModelUser', 'App\Models\Post' => 'ModelPost'])

// is equivalent to

<?php use \App\Models\User as ModelUser; use \App\Models\Post as ModelPost; ?>

and old syntax still works

@use('App\Models\User')

// is equivalent to

<?php use \App\Models\User; ?>

// and
@use('App\Models\User', 'ModelUser')

// is equivalent to

<?php use \App\Models\User as ModelUser; ?>

@MrPunyapal
Copy link
Contributor Author

I have created a new PR referenced to #49478
@taylorotwell

@MrPunyapal MrPunyapal changed the title Add support for array-based use statements in Blade templates [10.x] Add support for array-based use statements in Blade templates Dec 23, 2023
@taylorotwell
Copy link
Member

I'm not sure I really want to complicate this code further. Single use statement is in line with PHP's own syntax anyways.

@MrPunyapal MrPunyapal deleted the adding-multiple-statement-support-to-use-dir branch December 24, 2023 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants