Settings

Estimated reading: 2 minutes

We’ve tried our best to ease the life of developers. Mostly, developers just want to add just some inputs on the settings page. In such a case, you can add them to the module.json file and Akaunting will display your module under the Settings page.

All you have to do is to fill the settings array like the following:

"settings": [
     {
         "type": "text",
         "name": "header",
         "title": "my-blog::general.header",
         "icon": "fa fa-user",
         "attributes": {
             "required": "required"
         },
         "rules": "required|string"
     },
     {
         "type": "radio",
         "name": "enable_comments",
         "title": "my-blog::general.enable_comments",
         "enable": "general.yes",
         "disable": "general.no",
         "attributes": {},
         "rules": "integer|boolean"
     },
     {
         "type": "textarea",
         "name": "meta_description",
         "title": "my-blog::general.meta_description",
         "attributes": {},
         "rules": "nullable|string"
     }
 ]

Custom Settings

If your settings page needs a little bit more action then you can listen to the SettingShowing event and create your own route, controller, and view files.

Here is a listener example:

<?php

namespace Modules\MyBlog\Listeners;

use App\Events\Menu\SettingsCreated as Event;

class AddToSettingsMenu
{
    public function handle(Event $event): void
    {
        $event->menu->route('my-blog.settings.edit', trans('my-blog::general.name'), [], 180, [
            'icon' => 'edit',
            'search_keywords' => trans('my-blog::general.description'),
        ]);
    }
}

You can check the built-in Akaunting modules as live examples. The Offline Payments module ships with a custom settings page and the My Blog module uses the module.json file.

Share this Doc

Settings

Or copy link

CONTENTS