How to make redirect with $_GET parameter laravel?
How to make redirect url after user successfully logged in but on dynamic route for example
User login with url domain.com/login?next=/next/route << url encoded ,
thrn user redirect to /next/route route??
After using the default Laravel Authentication you should have a file located at app/Http/Controllers/Auth/LoginController.php
, if you do not create this new controller:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use App\Http\Controllers\Auth\ActivationService;
class LoginController extends Controller
{
public function __construct(ActivationService $activationService)
{
$this->middleware('guest', ['except' => 'logout']);
$this->activationService = $activationService;
}
}
Then you need to add a new method in that controller like so:
protected function authenticated(Request $request, $user)
{
return redirect($request->get('next'));
}
Then inside of your login form you will need to have the following hidden input:
<input type="hidden" name="next" value="{{ {{ app('request')->input('next') }} }}">
Hope that helps :)
Thanks.
thanks tony
Like this post Nice