Laravel操作未定义错误,但操作在控制器中定义

I keep getting an error that the action is not defined in my controller, but it is. I can access the index action, but not the processOrder action.

Below is my controller and my routes file.

namespace App\Http\Controllers\ThirdPartyAPI;

use App\Order;
use App\ThirdPartyAPI;
use GuzzleHttp\Client;
use App\Jobs\ThirdParyOrders;
use App\ThirdParty\ThirdPartyAPI;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class OrdersController extends Controller
{
    public function index ()
    {
        // list orders
    }

    public function processOrder()
    {
        // some logic here
    }
 }

If my I call the action "@index" in my routes/web.php file, it works and it returns the url, but if I change the "@index" to "@processOrder", it throws the error.

Ie. this works:

Route::get('thirdparty/process-order', function() {
    return action('ThirdPartyApi\OrdersController@index');
});

But this doesn't:

Route::get('thirdparty/process-order', function() {
    return action('ThirdPartyApi\OrdersController@processOrder');
});

I'm not sure where I'm missing the plot.

I've tried to quit and then re-run:

php artisan serve

I've also tried

composer dump-autoload

Still not sure what the problem was initially, but I've managed to get it working by using a different method. Intead of using a closure, I do it like this:

Route::get('thirdparty/{thirdparty_client}/process-order/{order}', 'ThirdPartyApi\OrdersController@processOrder');

This seems to do the trick. I didn't know that I could pass multiple parameters to the controller in this way, but this is working 100%.

I think you should have to try this as route.

Route::any("thirdparty/process-order", "ThirdPartyApi\OrdersController@processOrder");