简体   繁体   中英

Redirect to route not redirecting in laravel

I've been using Laravel-5.8.35 . I was invoking a GET request through a form. On my route, I redirected the form action to the same controller where the form was submitted but redirected through a different route, as,

$router->get('/merchant/sd-refund', 'Reports\ReportController@refundSecurityDeposit');

And, in my refundSecurityDeposit method, I called my SohojSdRefundService service,

    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,

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. I redirected another service like this, which is working fine though. Could anyone suggest what I could be implementing wrong here? TIA.

You need to return a result in refundSecurityDeposit fucntion

public function refundSecurityDeposit(Request $request)
{

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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