dimanche 3 juillet 2016

Laravel 5: Redirecting to external link on POST request

The function below is called through a POST request. I need to retrieve URL from my database and open the link in a new tab. I'm using the Redirect::away() function for this. But it gives a MethodNotAllowedHttpException. I have tried calling this function in a GET request and it works perfectly fine.

public function generateURL(Request $request) {

    $screenRow = \App\ScreenshotRow::find($request->input('row_ID'));
    $baseURL = $screenRow->BaseURL;

    $screenshot = \App\Screenshot::where('Setname', '=', $screenRow->Setname)->get();
    $pageURL = $screenshot[0]['PageURL'];

    if ($baseURL == "") {
        return Redirect::away($PageURL);
    }

    else
        return Redirect::away($baseURL);
}

Is there any way to calling this function in response to a POST request?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire