The Basics
Routes
Routes define the paths that exist in your application as well as references to elements, code and other settings that are apply at "route level".
Overview
Stellify leverages Laravel's existing routing to match requests to resources. The key difference is that Stellify will look for the path in a table containing routes (and associated definitions that contain references to other resources that should be loaded for the given path, such as elements) rather than a file, as would ordinarily be the case.
A route also represents a level in the sense that properties set at route level will override properties set at project level, an example being a page's meta title.
Basic Routes
A basic route object will look something like this:
{
type: "layout",
id: "3973cbe4-ad11-461a-b36a-edd91d979621",
name: "New Page",
type: "web",
method: "GET",
public: true,
path: "myroute"
}
This route can be accessed by navigating to:
https://yourdomain.com/myroute
Route Parameters
Sometimes you will need to capture segments of the URI within your route. For example, you may need to capture a user's ID from the URL. You may do so by defining route parameters:
{
type: "layout",
id: "3973cbe4-ad11-461a-b36a-edd91d979621",
name: "New Page",
type: "web",
method: "GET",
public: true,
path: "orders/{orderId}",
}
In this case the value that takes the place of the orderId
parameter will be accessible on both the server and the client in the global store object as orderId
(see variables).
API Routes
To create an api route, simply prepend '/api' to the route path i.e. `/api/my-api-route`.
Stellify uses Laravel Sanctum on the server to provide an authentication system for SPAs, Mobile Applications and token based APIs. You can develop methods to work with Laravel Sanctum's classes using the code editor.
Controllers
To attach a controller and call its method from a route you simply add the uuid of the controller and the method. If you omit adding the method uuid then Stellify will assume you are intending to call the index
method.
{
type: "layout",
id: "3973cbe4-ad11-461a-b36a-edd91d979621",
name: "New Page",
type: "web",
method: "GET",
public: true,
controller: "b6d19498-e13e-4381-a50a-7eb8280aab5f",
controller_method: "f2c3b1d4-8e5a-4c6b-9f0d-7e8c9a1b2c3d"
}
You can review the full Routes API specification here.