How can I add a new menu and controller in Vendor Panel?

Hello.
Hope you are doing well.
I was trying to add a new menu to allow the Vendors can register their bank details so that Administrator can send their money to their bank directly at 1st day of every month.
I developed a new addon for that and added menu details to the /schemas/menu/menu_vendor.php file.

<?php
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}

$schema['central']['settings']['items']['bank_settings'] = [
    'href' => 'company_bank_details.manage',
    'position' => 700,
    'title' => "Bank Setting"
];

return $schema;

Of course, I added the /controllers/backend/company_bank_details.php on the addons folder.

<?php
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}

use Tygh;
use Tygh\Addons\StripeMonthlyAutoPayout\CompanyBankManager;

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($mode == 'manage') {
        $company_id = $auth['company_id'];
        $bank_details = $_REQUEST['bank_details'];

        if (!$company_id) {
            return [CONTROLLER_STATUS_DENIED];
        }

        $manager = new CompanyBankManager();
        $manager->updateCompanyDetails($company_id, $bank_details);

        fn_set_notification('N', "Notice", "Company Bank Information updated");
        return [CONTROLLER_STATUS_OK, 'company_bank_details.update'];
    }
}

if ($mode == 'manage') {
    // $company_id = $auth['company_id'];

    // echo $company_id;

    // if (!$company_id) {
    //     return [CONTROLLER_STATUS_DENIED];
    // }

    $manager = new CompanyBankManager();
    $bank_details = $manager->getCompanyDetails($company_id);

    Tygh::$app['view']->assign('company_bank_details', $bank_details);
}

But I am getting the 403 Access Denied issue on the Vendor layout edit.

Could you please help me how we can fix this issue?

Please do not forget to add a template

/design/backend/templates/addons/YOUR_ADDON/views/company_bank_details/manage.tpl

1 Like