2017 © Pedro Peláez
 

library jsroute

Access Laravel Route helper functions, from JavaScript.

image

jeylabs/jsroute

Access Laravel Route helper functions, from JavaScript.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Generate the laroute.js

To access the routes, we need to "port" them over to a JavaScript file:, (*1)

php artisan laroute:generate

With the default configuration, this will create a public/js/laroute.js file to include in your page, or build., (*2)

<script src="/js/laroute.js"></script>

Note: You'll have to laroute:generate if you change your routes., (*3)

JavaScript Documentation

By default, all of the functions are under the laroute namespace. This documentation will stick with this convention., (*4)

action

Generate a URL for a given controller action., (*5)

/** 
 * laroute.action(action, [parameters = {}])
 *
 * action     : The action to route to.
 * parameters : Optional. key:value object literal of route parameters.
 */

laroute.action('HomeController@getIndex');

route

Generate a URL for a given named route., (*6)

/**
 * laroute.route(name, [parameters = {}])
 *
 * name       : The name of the route to route to.
 * parameters : Optional. key:value object literal of route parameters.
 */

 laroute.route('Hello.{planet}', { planet : 'world' });

url

Generate a fully qualified URL to the given path., (*7)

/**
 * laroute.url(name, [parameters = []])
 *
 * name       : The name of the route to route to.
 * parameters : Optional. value array of route parameters.
 */

 laroute.url('foo/bar', ['aaa', 'bbb']); // -> /foo/bar/aaa/bbb

Generate a html link to the given url., (*8)

/**
 * laroute.link_to(url, [title = url, attributes = {}]])
 *
 * url        : A relative url.
 * title      : Optional. The anchor text to display
 * attributes : Optional. key:value object literal of additional html attributes.
 */

 laroute.link_to('foo/bar', 'Foo Bar', { style : "color:#bada55;" });

Generate a html link to the given route., (*9)

/**
 * laroute.link_to_route(name, [title = url, parameters = {}], attributes = {}]]])
 *
 * name       : The name of the route to route to.
 * title      : Optional. The anchor text to display
 * parameters : Optional. key:value object literal of route parameters.
 * attributes : Optional. key:value object literal of additional html attributes.
 */

 laroute.link_to_route('home', 'Home');

Generate a html link to the given action., (*10)

/**
 * laroute.link_to_action(action, [title = url, parameters = {}], attributes = {}]]])
 *
 * action     : The action to route to.
 * title      : Optional. The anchor text to display
 * parameters : Optional. key:value object literal of route parameters.
 * attributes : Optional. key:value object literal of additional html attributes.
 */

 laroute.link_to_action('HelloController@planet', undefined, { planet : 'world' });

PHP Documentation

Ignore/Filter Routes

By default, all routes are available to laroute after a php artisan laroute:generate. However, it is sometimes desirable to have laroute ignore certain routes. You can do this by passing a laroute route option., (*11)

Route::get('/ignore-me', [
    'laroute' => false,
    'as'      => 'ignoreme',
    'uses'    => 'IgnoreController@me'
]);

Route::group(['laroute' => false], function () {
    Route::get('/groups-are-super-useful', 'GroupsController@index');
});

The Versions

02/06 2015

dev-master

9999999-dev

Access Laravel Route helper functions, from JavaScript.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sureshkumar

laravel javascript routing routes

02/06 2015

v1.0.2

1.0.2.0

Access Laravel Route helper functions, from JavaScript.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sureshkumar

laravel javascript routing routes

28/05 2015

v1.0.1

1.0.1.0

Access Laravel Route helper functions, from JavaScript.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sureshkumar

laravel javascript routing routes

28/05 2015

v1.0.0

1.0.0.0

Access Laravel Route helper functions, from JavaScript.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sureshkumar

laravel javascript routing routes