Title, I know it can be obtained in the controller, but it is possible to get access to a route or method name in the form of a direct function in the blade template. Does Laravel offer a similar approach?
Reply content:
Title, I know it can be obtained in the controller, but it is possible to get access to a route or method name in the form of a direct function in the blade template. Does Laravel offer a similar approach?
The method is still there, but this practice should not be encouraged, and you can get (inject) the service directly through the @inject statement
Example
@inject('request', 'Illuminate\Http\Request')request method: {{ $request->getMethod() }}
Document
Http://laravel.com/docs/5.1/blade#service-injection
OK. Write a function directly
function getCurrentRouteMethod(){ return app('request')->getMethod();}
Called directly in the template.
{{ getCurrentRouteMethod() }}