laravel 旧路由 url

laravel legacy route url

我有 2 条路线 POST 方法

Route::post('/payment/checkOrder','Finance\PaymentCallbackController@checkOrder');
Route::post('/payment/paymentAviso', 'Finance\PaymentCallbackController@paymentAviso');

我如何为这些路由创建遗留链接?

/plat.php?paysystem=5&method=checkOrder
/plat.php?paysystem=5&method=paymentAviso

你可以有一个接收方法字符串的路由,然后根据它调用所需的函数。

Route::post('/payment/{method}','Finance\PaymentCallbackController@handler');
// PaymentCallbackController.php 
public function handler(Request $request){
   // make sure to validate what methods get sent here
   $this->{$request->method}($request); 
   // use $this if its in this controller, for otherControllers 
   // try something with the looks of  app('App\Http\Controllers\OtherControllerController')->{$request->method}->($request);
}

添加这条路线:

Route::post('/plat.php', 'SomeController@action');

在你的控制器函数中:

// SomeController.php

public function someAction()
{
    $paysystem = $request->query('paysystem');
    $method = $request->query('method');
    // some logic here
    return view('something');
}