[英]Redirect to route not redirecting in laravel
I've been using Laravel-5.8.35
.我一直在使用
Laravel-5.8.35
。 I was invoking a GET
request through a form.我正在通过表单调用
GET
请求。 On my route, I redirected the form
action to the same controller
where the form was submitted but redirected through a different route, as,在我的路线上,我将
form
操作重定向到相同的controller
表单已提交但通过不同的路线重定向,例如,
$router->get('/merchant/sd-refund', 'Reports\ReportController@refundSecurityDeposit');
And, in my refundSecurityDeposit
method, I called my SohojSdRefundService
service,而且,在我的
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);
}
While my SohojSdRefundService
service was done handling, I wanted to redirect the route to another route, as,当我的
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');
}
}
Respectively, instead of redirecting to that route, the page happens to be still on the /merchant/sd-refund?...
where the form
was submitted initially.分别地,该页面没有重定向到该路由,而是恰好仍在
/merchant/sd-refund?...
最初提交form
的位置。 I redirected another service like this, which is working fine though.我重定向了另一个这样的服务,但它工作正常。 Could anyone suggest what I could be implementing wrong here?
任何人都可以建议我在这里实施错误吗? TIA.
TIA。
You need to return a result in refundSecurityDeposit fucntion您需要在refundSecurityDeposit 函数中返回结果
public function refundSecurityDeposit(Request $request)
{
return $this->execRefundRequest($userId, $reason, $sdAmount);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.