Skip to content

Routing

Abhinav Saraswat edited this page Nov 24, 2016 · 2 revisions

For defining API routes, you need to use ApiRoute façade instead of regular Route façade. ApiRoute extends Laravel's Route, so it works just like it, with some extra features.

Version

The package supports API versions. To specify which version a set of routes belongs to:

ApiRoute::version(["v1", "v2"], function() {
   ...
});

All the routes/route groups within this will belong to API v1 and v2.

If you do not specify versions for a route, its version is set according to defaultVersion option in config. If defaultVersion is null, route is not given any version, else, it is given the defaultVersion.

Resource

ApiRoute::resource method works just like Route::resource, except that it also adds relations endpoint to the routes.

Clone this wiki locally