方法 SendMoneyController::index 不存在

Method SendMoneyController::index does not exist

我正在使用 Laravel 8,我的应用程序在本地运行良好。现在我将应用程序上传到专用服务器,但出现以下错误:

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

但是,这个方法是存在的,而且在本地服务器上运行良好。

控制器

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');
    )};
)};

请验证 UserSendMoneyController 中的命名空间

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

尝试这些更改,如果注释了这一行然后也取消注释在“app\provider\RouteServiceProvider”

 protected $namespace = 'App\Http\Controllers';

为什么要使用其值已设置为 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)
            ]);
    }