【发布时间】:2021-07-22 16:24:31
【问题描述】:
我一直在使用Laravel-5.8.35。我正在通过表单调用GET 请求。在我的路线上,我将form 操作重定向到提交表单但通过不同路线重定向的同一controller,例如,
$router->get('/merchant/sd-refund', 'Reports\ReportController@refundSecurityDeposit');
并且,在我的refundSecurityDeposit 方法中,我调用了我的SohojSdRefundService 服务,
public function refundSecurityDeposit(Request $request)
{
// $userId, $reason, $sdAmount was fetched from the $request instance
$this->execRefundRequest($userId, $reason, $sdAmount);
}
public function execRefundRequest($userId, $reason, $sdAmount)
{
// here the API service request data was handled,
// and stored in $data instance
return SohojSdRefundService::callSdRefundApi($data);
}
当我的SohojSdRefundService 服务完成处理时,我想将路由重定向到另一个路由,因为,
class SohojSdRefundService
{
public function __construct()
{
}
public static function callSdRefundApi($requestData)
{
// call to other methods inside the class to handle the API response,
// and then return to the same route which isn't working
return redirect('/admin/merchant/list');
}
}
相应地,该页面并未重定向到该路由,而是恰好位于最初提交form 的/merchant/sd-refund?... 上。我重定向了另一个这样的服务,但它工作正常。任何人都可以建议我在这里实施错误吗? TIA。
【问题讨论】: