dimanche 4 décembre 2016

Laravel make view request doesn't change in the URL

I am using middleware to redirect a user if they don't meet certain criteria (haven't accepted terms and conditions!). They are redirected to /terms.

Middleware:

public function handle($request, Closure $next)
    {
        if (Auth::user()->terms === 0) {
            return redirect()->route('getTerms');
        }

        return $next($request);
    }

The above works perfectly.

Once the user 'accepts' the terms and conditions, I want to redirect them to the homepage (which currently works), however, the URL doesn't change. It still stays on /terms, even though they're on the homepage.

Controller 'accept terms':

$user = User::find(Auth::id());
$user->terms = 1;
$user->save();

return view('home');

The reason I need the URL to redirect back to /home is because I have a layout condition, that I need a view to be included when the user is not on the /term url.

Layout condition:

 @if(!Request::is('terms'))
     @include('layouts.check')
 @endif

Why isn't the return view('home); working the same as it is in other functions?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2h2Oz7K
via IFTTT

Aucun commentaire:

Enregistrer un commentaire