laravel遗产路线网址

时间:2018-03-16 09:42:33

标签: php laravel legacy

我有两条使用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

2 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

添加此路线:

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