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

[5.7] Allow various callable syntax for actions #27042

Closed
wants to merge 2 commits into from
Closed

[5.7] Allow various callable syntax for actions #27042

wants to merge 2 commits into from

Conversation

alies-dev
Copy link

it allows to use the following native PHP callable syntax:

action([new SomeController, 'someAction'])
action('\App\Http\Controllers\SomeController::someAction')

Previously added by #24738 syntax is also supported:

action([SomeController::class, 'someAction'])

as well as original Laravel syntax:

action('\App\Http\Controllers\SomeController@someAction'])

Having this update you can use the following syntax from a controller:

return redirect()->action([$this, 'someAction'])
// what is the same as:
return redirect()->action([self::class, 'someAction'])

it allows to use the following syntax:
action([new SomeController, 'someAction'])
action('\App\Http\Controllers\SomeController::someAction')

Previously added by #24738 syntax is also supported:
action([SomeController::class, 'someAction'])

as well as original Laravel syntax:
action('SomeController@someAction'])
action(SomeController::class.'@someAction'])

Having this update you can use the following syntax from a controller:
return redirect()->action([$this, 'someAction'])
what is the same as:
return redirect()->action([self::class, 'someAction'])
@taylorotwell
Copy link
Member

I don't think it's a smart use case to new up controller objects just to create URLs.

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