AccEasy :: Accounting Made Easy

  1. Home
  2. Docs
  3. AccEasy :: Accounting Made Easy
  4. Module Development
  5. Developing Modules

Developing Modules

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:

  1. Create a controller with the name “DataController”.
  2. DataController acts as the main controller for interacting with the POS.
  3. It helps many different purposes as described in the further section.

Adding New permission related to modules:

  1. 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 ] ];
  2. Add migrations to create the permissions in the module

Adding menu from modules:

  1. Create a function modifyAdminMenu in DataController which returns the menu in this format:Copy to Clipboard1Menu::modify(‘admin-sidebar-menu’, function ($menu) { $menu->dropdown(“Label”, function ($sub) { $sub->url( action(‘AnyController@index’), “Label”, [‘icon’ => ‘fa fa-list’, ‘active’ => “conditions to make menu active”)] ); } ) });1Menu::modify(‘admin-sidebar-menu’, function ($menu) { $menu->dropdown(“Label”, function ($sub) { $sub->url( action(‘AnyController@index’), “Label”, [‘icon’ => ‘fa fa-list’, ‘active’ => “conditions to make menu active”)] ); } ) });
  2. Add “AdminSidebarMenu” middleware in routes.

Adding New taxonomy or category modules:

  1. Define a function addTaxonomies() in the DataController which returns an array in this format:

Copy to Clipboard

1

return [ ‘hrm_department’ => [ ‘heading’ => __(‘superhero::lang.departments’), ‘sub_heading’ => __(‘superhero::lang.manage_departments’), ‘enable_taxonomy_code’ => true, ‘taxonomy_code_label’ => __(‘superhero::lang.department_id’), ‘taxonomy_code_help_text’ => __(‘superhero::lang.department_code_help’), ‘enable_sub_taxonomy’ => false ] ];

1

return [ ‘hrm_department’ => [ ‘heading’ => __(‘superhero::lang.departments’), ‘sub_heading’ => __(‘superhero::lang.manage_departments’), ‘enable_taxonomy_code’ => true, ‘taxonomy_code_label’ => __(‘superhero::lang.department_id’), ‘taxonomy_code_help_text’ => __(‘superhero::lang.department_code_help’), ‘enable_sub_taxonomy’ => false ] ];

2. Add the taxonomy to menu with url parameter taxonomy type as type, example:

Copy to Clipboard

1

$sub->url( action(‘TaxonomyController@index’) . ‘?type=hrm_department’, __(‘superhero::lang.departments’), [‘icon’ => ‘fa fa-tags’, ‘active’ => request()->get(‘type’) == ‘hrm_department’] );

1

$sub->url( action(‘TaxonomyController@index’) . ‘?type=hrm_department’, __(‘superhero::lang.departments’), [‘icon’ => ‘fa fa-tags’, ‘active’ => request()->get(‘type’) == ‘hrm_department’] );

Parsing notifications related to modules:

  1. Define a function parse_notification($notification) in the DataController which has a notification instance as an argument
  2. Check the type of notification and return the formated notification data as an array. For example:Copy to Clipboard1if ($notification->type == ‘Modules\Superhero\Notifications\DocumentShareNotification’) { $notification_data = [ ‘msg’ => “One document has been shared”, ‘icon_class’ => ‘fa fa-envelope-open’, ‘link’ => action(‘\Modules\Superhero\Http\Controllers\DocumentController@index’), ‘read_at’ => $notification->read_at, ‘created_at’ => $notification->created_at->diffForHumans() ]; }1if ($notification->type == ‘Modules\Superhero\Notifications\DocumentShareNotification’) { $notification_data = [ ‘msg’ => “One document has been shared”, ‘icon_class’ => ‘fa fa-envelope-open’, ‘link’ => action(‘\Modules\Superhero\Http\Controllers\DocumentController@index’), ‘read_at’ => $notification->read_at, ‘created_at’ => $notification->created_at->diffForHumans() ]; }

NOTE: To display a notification you should save the notification in the database using toDatabase() method in the Notification class

Was this article helpful to you? Yes No

How can we help?