0
I would like to know in Laravel, when saying the name of the route, it accepts the variable, instead of the name itself, as for example:
Example: Instead of being like this:
{{ route('minhaRota') }}
Be like that:
var minhaRota = 'minhaRota'
{{ route( minhaRota ) }}
Only this way he gives me an undefined constant warning
I’m trying to do this with javascript
Since I want to repurpose code, and I will use the same page for other types of operations, I would not like to keep copying code to another file, I would just send a variable with the current route to finish certain operation back to where I was.
To get the current route I’m using so:
let currentUrl = '{{ Route::getCurrentRoute()->action['as'] }}'
Then I send this current url to a form so that when it finishes the operation (save, edit) it goes back to where it was before the currentUrl
The way you did it is like there is a constant in PHP. Javascript and PHP do not share the same variable, they are different things. Tell us what you want to do!
– novic
Oops, good afternoon the best way to do this is to use a lib that already exists, the name is laroute, gives a search, worth it. https://github.com/aaronlord/laroute
– arllondias
Possible duplicate of Match php variable to javascript variable
– Wallace Maxters