Skip to content

Instantly share code, notes, and snippets.

@omitobi
Forked from molayli/helpers.php
Created February 13, 2019 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omitobi/4f30bd5bd8734d987b7f61a1f877f79e to your computer and use it in GitHub Desktop.
Save omitobi/4f30bd5bd8734d987b7f61a1f877f79e to your computer and use it in GitHub Desktop.
Laravel redirect without return statment
<?php
//.....
if(!function_exists('freeRedirect')){
function freeRedirect($to = '/'){
throw new \Illuminate\Http\Exception\HttpResponseException(redirect($to));
}
}
//.............
//usage
class AbcController extends Controller{
public function aMethod(){
freeRedirect('/to/another/route');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment