Custom routing

By default a few routes are bundled with this package to handle the load @ action requests.

There are a few reason why you want to have more control over how you route those requests:

  • You would like to make use of middleware to validate or secure access
  • You would want (nearly) full control over the url

Data route

It's easy to change the route, first let me show you the default route:

Route::get('lists/{table}', [
    'uses' => '\DragonFly\Lists\Http\Controllers\DataController@load', 
    'as' => 'lists.load'
]);

The most important parts being that a {table} parameter is present in the URL and that the route is named.
When you create your own route, of course it should point to that same controller.

Change the route globally

If you want to route all the dataTables AJAX requests you'll have to open up app/config/lists.php and change the route key to the name of the route you want to use.

easy enough, all requests will be sent through there from now on.

Change the route locally

In case you just want to change the route for a specific Table definition, you can assign the route's name to that definition's protected $route property.

By default it's set to false, so it gets set to the globally defined route.

    /**
     * The name of the route to use for the data requests.
     *
     * @var string|false
     */
    protected $route = 'lists.load';

Action route

It's easy to change the route, first let me show you the default route:

Route::get('lists/{table}/{action}', [
    'uses' => '\DragonFly\Lists\Http\Controllers\DataController@load',
    'as' => 'lists.perform'
]);

The most important parts being that a {table} & {action} parameters are present in the URL and that the route is named.
When you create your own route, of course it should point to that same controller.

Change the route globally

If you want to route all the action requests you'll have to open up app/config/lists.php and change the action_route key to the name of the route you want to use.

easy enough, all requests will be sent through there from now on.

Change the route locally

In case you just want to change the route for a specific Table definition, you can assign the route's name to that definition's protected $action_route property.

By default it's set to false, so it gets set to the globally defined route.

    /**
     * The name of the route to use for the action requests.
     *
     * @var string|false
     */
    protected $action_route = 'lists.perform';