繁体   English   中英

重定向到不在 laravel 中重定向的路由

[英]Redirect to route not redirecting in laravel

我一直在使用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');
    }
}

分别地,该页面没有重定向到该路由,而是恰好仍在/merchant/sd-refund?...最初提交form的位置。 我重定向了另一个这样的服务,但它工作正常。 任何人都可以建议我在这里实施错误吗? TIA。

您需要在refundSecurityDeposit 函数中返回结果

public function refundSecurityDeposit(Request $request)
{

   return $this->execRefundRequest($userId, $reason, $sdAmount);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM