0

What is the best approach to generate Laravel route links inside Vue component?

So I see two approaches, either generate them in view, with Laravel's route functions (link_to_route(), etc...), and just pass them as component properties.

Or well just hard code them, inside the template (seems like the worse option of the 2).

Is there any other approach I could take? As both of these, feels kinda hacky.

1 Answer 1

2

Take a look at this package:

https://github.com/aaronlord/laroute

It builds all the js routes from your laravel route files using an artisan command

php artisan laroute:generate

Then it provides js versions of the laravel route helper functions.

Sign up to request clarification or add additional context in comments.

1 Comment

oh thats interesting, will definitely check it out. Thanks! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.