Mail: [email protected]
Phone: +1(424)231-4091
Everything you need to know about NexoPOS.
By registering routes, you let NexoPOS know how it can take the user to your routes. The routes system uses Laravel Routing. Here we'll just cover the specificity that is required to understand how the routes work for modules.
Every module comes with 2 files within the "Routes" folder that are used for routing :
Further details can be found here.
Public Routes are likely to be available for the public. These routes usually don't use "dashboard" as a prefix and most of the time don't require permissions to be accessible.
Private Routes are routes that use "dashboard" as a prefix. These routes are means to be administrative routes and design all routes that take to dashboard interfaces.
Here, we'll register a route that takes to a page on the dashboard with an ending slug "foobar".
Note that here we're loading a controller that is supposed to be registered in the "Http/Controllers" folder with the filename FooBarController.php.
If you want to create a controller for your module, you can still use the command :
php artisan modules:controller {module_namespace} {controller_class_name}
So to create a FooBarController as a controller, we'll use the following command :
php artisan modules:controller FooBar FooBarController
As you can protect menus with permissions, you can also protect routes using permissions. Here, we'll define the permission on a middleware like so.
Here, the middleware name to use is "NsRestrictMiddleware" which accepts as a parameter the permission (or an array of permissions), we'll require to allow access to the route. In our example, we've used "can.fly" as permission.
If you would like to protect some routes with authentication, you'll need to attach a middleware to those routes. Here is an example :
We're here using the middleware "Authenticate" to protect the routes defined within the group. Note that "SubstituteBindings" is also required to ensure the model binding works for the modules.