1

I am using Laravel 8, and my application is working fine locally. Now I upload the app to a dedicated server and I'm getting the error below:

BadMethodCallException Method App\Http\Controllers\User\SendMoneyController::index does not exist.

However, this method exists and it's working fine on the local server.

Controller

class SendMoneyController extends Controller
{
    use AmlRulesVerification;

    protected $sendMoneyInterface, $transactionInterface, $recipientInterface, $cardInterface, $homeInterface;

    public function __construct(
        SendMoneyInterface $sendMoneyInterface,
        TransactionInterface $transactionInterface,
        RecipientInterface $recipientInterface,
        CardInterface $cardInterface,
        HomeInterface $homeInterface
    ) {
        $this->sendMoneyInterface = $sendMoneyInterface;
        $this->transactionInterface = $transactionInterface;
        $this->recipientInterface = $recipientInterface;
        $this->cardInterface = $cardInterface;
        $this->homeInterface = $homeInterface;
    }

    public function index(Request $request, $id = null)
    {
        $transaction = $this->sendMoneyInterface->getTransaction($request, $id);
        if (isset($transaction['transaction']->card) && $transaction['transaction']->card) {
            return redirect()->route('send.money.confirmation', ['id' => $id]);
        }
        return view('customers.send_money.index',
            [
                'data' => $transaction,
                'countries' => $this->homeInterface->landingViewData($request)
            ]);
    }
}

web.php

Route::group(['middleware'=>'languageSwitcher'],function () {
    Auth::routes(['verify' => true]);
    Route::get('/', [HomeController::class, 'landingView'])->name('landing.view');
    Route::get('users/registration', [UserController::class, 'showRegisterForm'])->name('user.registration');
    Route::get('localization/change/language', [LanguageSwitcher::class, 'changeLanguage'])->name('LangChange');
    Route::post('/set/email/session', [UserController::class, 'setEmailInSession']);

    Route::group(['middleware'=>'auth'],function () {
        Route::get('/home', [HomeController::class, 'index'])->name('home');
        Route::get('/send/money', [UserSendMoneyController::class, 'index'])->name('send.money.index');
    )};
)};
Karl Hill
  • 12,937
  • 5
  • 58
  • 95
  • 1
    On which file/line does it throw the error ? – Kevin Jul 02 '21 at 12:13
  • did you update the composer? – hammad khan Jul 02 '21 at 12:14
  • when i update I show Do not run Composer as root/super user! See https://getcomposer.org/root for details Loading composer repositories with package information Warning from https://repo.packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/ Updating dependencies (including require-dev) Killed – Irshad Khan Jul 02 '21 at 12:19

2 Answers2

0

Please Verify the namespace in the UserSendMoneyController

Route::get('/send/money', [User\UserSendMoneyController::class, 'index'])->name('send.money.index');

try these changes if commented this line then uncomment too In "app\provider\RouteServiceProvider"

 protected $namespace = 'App\\Http\\Controllers';
Waleed Muaz
  • 737
  • 6
  • 17
0

Why are you using a variable whose value you have already set to null?

 public function index(Request $request)
    {
        $transaction = $this->sendMoneyInterface->getTransaction($request);
        if (isset($transaction['transaction']->card) && $transaction['transaction']->card) {
            return redirect()->route('send.money.confirmation');
        }
        return view('customers.send_money.index',
            [
                'data' => $transaction,
                'countries' => $this->homeInterface->landingViewData($request)
            ]);
    }
Yunus Kocabay
  • 133
  • 10