pichicacax / laravel-js-route
Convert all your routes and enable named route usage in Javascript
v1.0.0
2020-02-14 03:09 UTC
Requires
- php: ^7.2
This package is auto-updated.
Last update: 2024-04-18 07:07:32 UTC
README
Convert all your routes and enable named route usage in the front-end.
Laravel Support
Compatible with Laravel 6.x, 5.8, and 5.7.
Installation
- Install via Composer
composer require pichicacax/laravel-js-route
- Add the following service provider to your config/app.php file
Pichicacax\LaravelJsRoute\LaravelJsRouteServiceProvider::class
Usage
Generating routes for JS
php artisan route:js
By default, the JS target is resources/assets/js/routes.js. You may change this by providing a custom target
php artisan route:js /path/custom-target.js
JS usage
import {route} from './routes';
Generate a URL using a named route
route("welcome")
Providing parameters
route("foo.edit", fooId)
route("bar.index", { param1: value1, param2: value2 })