Mail: [email protected]
Phone: +1(424)231-4091
Everything you need to know about NexoPOS.
By registering routes, you let NexoPOS 4.x 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 come with 2 files within the "Routes" folder that are using 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 on 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 "ns.restrict" which accepts as a parameter the permission we'll require to allow access to a route. In our example, we've used "can.fly" as permission. Note that between the middleware name and the permission there is a colon (:) used as a separator.
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.