Add a New Menu Item on Akaunting

Hello guys, this is a really fast receipe to create a new menu item from your module on Akaunting 2.0.13

  1. Make your Module & Listener
  2. Register your Listener
  3. Clear cache and refresh your browser

Make your Module & Listener

php artisan module:make my-menu
php artisan module:make-listener AddMenu my-menu

Register your Listener

Add to your Modules\MyMenu\Providers\Event.php the next lines:

use App\Events\Menu\AdminCreated;
use Modules\MyMenu\Listeners\AddMenu;
...
class Event extends Provider
{
...
    protected $listen = [
...
        AdminCreated::class => [
            AddMenu::class,
        ],
    ];
...

Edit your listener Modules\MyMenu\Listeners\AddMenu.php

...
    public function handle($event)
    {
...
        // Add child to existing menu item
        $item = $event->menu->whereTitle(trans_choice('general.sales', 2));
        $item->url('my-blog/posts', 'Posts', 4, ['icon' => '']);

        // Add new menu item
        $event->menu->add([
            'url' => 'my-blog/posts',
            'title' => 'Posts',
            'icon' => 'fas fa-pen',
            'order' => 5,
        ]);
    }
Alejandro M.

Ingeniero Mexicano especialista en Seguridad Informática. Conocimientos en Cisco con la certificación Cisco Certified Network Professional - Security, Fortinet con ahora NSE-4, Certified Ethical Hacker. Trabajo con sistema operativos Linux para servidores de servicios web, dns, balanceo de carga, etc... Fanático de los MMORPG