1
votes

I'm working on the backend side of a plugin and I'm having some issues getting it to work. I created all the plugin needed files, models, register things and so on but any time I try to access backend URL as per example http://alomicuba.dev/backend/alomicuba/balancerecharge I get a 404 error and I don't know what I''m doing wrong. This is the code on /plugins/alomicuba/balancerecharge/controllers/balancerecharge/BalanceRecharge.php file:

<?php namespace Alomicuba\BalanceRecharge\Controllers;

use Flash;
use BackendMenu;
use Backend\Classes\Controller;
use System\Classes\SettingsManager;
use Alomicuba\RechargeBalance\Models\Settings as BalanceRechargeSettings;

class BalanceRecharge extends Controller
{
    public $implement = [
        'Backend.Behaviors.FormController',
        'Backend.Behaviors.ListController'
    ];

    public $formConfig = 'config_form.yaml';
    public $listConfig = 'config_list.yaml';

    public $requiredPermissions = ['balancerecharge.*'];

    public $bodyClass = 'compact-container';

    public function __construct()
    {
        parent::__construct();

        BackendMenu::setContext('Alomicuba.BalanceRecharge', 'balancerecharge');
        SettingsManager::setContext('Alomicuba.BalanceRecharge', 'settings');
    }
}

And this is the Plugin.php code:

class Plugin extends PluginBase {

    /**
     * Returns information about this plugin.
     *
     * @return array
     */
    public function pluginDetails()
    {
        return [
            'name' => 'Balance Recharge',
            'description' => 'Plugin that allows users to recharge theirs balance through the PayPal payment gateway',
            'author' => 'Dynamo Technology Solutions',
            'icon' => 'icon-credit-card'
        ];
    }

    public function registerNavigation()
    {
        return [
            'bradmin' => [
                'label'       => 'Balance Recharge',
                'url'         => Backend::url('alomicuba/balancerecharge/balancerecharge'),
                'icon'        => 'icon-credit-card',
                'permissions' => ['brecharge.*'],
                'order'       => 500,

                'sideMenu' => [
                    'brecharge' => [
                        'label'       => 'Balance Recharge',
                        'icon'        => 'icon-credit-card',
                        'url'         => Backend::url('alomicuba/balancerecharge/balancerecharge'),
                        'permissions' => ['brecharge.*'],
                    ],
                ]

            ]
        ];
    }

    public function registerSettings()
    {
        return [
            'settings' => [
                'label' => 'Balance Recharge PayPal Configuration',
                'description' => 'Manage the settings for Balance Recharge.',
                'category' => 'AloMiCuba',
                'icon' => 'icon-cog',
                'class' => 'Alomicuba\BalanceRecharge\Models\Settings',
                'order' => 100
            ]
        ];
    }

    public function boot()
    {
        \App::register('Barryvdh\Omnipay\ServiceProvider');
        \Illuminate\Foundation\AliasLoader::getInstance()->alias('Omnipay', 'Barryvdh\Omnipay\Facade');

        UserModel::extend(function($model){
            $model->hasMany['payment'] = ['Alomicuba\BalanceRecharge\Models\Payment'];
        });

    }

    public function registerComponents()
    {
        return [
            'Alomicuba\BalanceRecharge\Components\Payment' => 'Payment'
        ];
    }

}

I'm missing something here?

1
can you past plugin.php codeAnand Patel
@anandpatel done, I added to the main post, also can you take a look to this post? Maybe you can give me a better answer than the one I have there since you has developed October plugins alreadyReynierPM
@anandpatel That works, could you answer so I can give you the points and please take a look to the other post I leave you, I'm stucked and don't know what else to doReynierPM

1 Answers

2
votes

In October CMS URL for controller is like

 domain-name/backend/author-name/plugin-name/controller-name

so in your case you can use

 alomicuba.dev/backend/alomicuba/balancerecharge/balancerecharge