UltimatePOS uses the Laravel-Module package for module development. So all the commands provided by this package will be used for the development.
Creating Module:
To create a module follow the commands as given in here
Let us assume you created a Modules called: Superhero
Config file:
Inside the new Modules which you created open the config file.
Superhero/Config/config.php
Add 2 configs here:
- name
- module_version
So it will be:
return [
‘name’ => ‘Superhero’,
‘module_version’ => “1.0”
];
Data Controller:
- Create a controller with the name “DataController”.
- DataController acts as the main controller for interacting with the POS.
- It helps many different purposes as described in the further section.
- Add function user_permissions() in the DataController which return multi-dimensional array containing arrays of all module permissions with key “value”, “label”, “default”
where value (string) is the name of the permission, label (string) is the label for the permission, and default (boolean) is the default checked or unchecked state of the permission on the rule add screen
Example:[ [ 'value' => 'superhero.create', 'label' => __('superhero::lang.add'), 'default' => false ], [ 'value' => 'superhero.update', 'label' => __('superhero::lang.edit'), 'default' => false ] ]; - Add migrations to create the permissions in the module
- Create a function modifyAdminMenu in DataController which returns the menu in this format:Copy to Clipboard
- Add “AdminSidebarMenu” middleware in routes.
Adding New taxonomy or category modules:
- Define a function addTaxonomies() in the DataController which returns an array in this format:
Copy to Clipboard
2. Add the taxonomy to menu with url parameter taxonomy type as type, example:
Copy to Clipboard
- Define a function parse_notification($notification) in the DataController which has a notification instance as an argument
- Check the type of notification and return the formated notification data as an array. For example:Copy to Clipboard
NOTE: To display a notification you should save the notification in the database using toDatabase() method in the Notification class