mardi 28 janvier 2020

Laravel 5 return redirect is not working as it should

I'm having a controller with some functions. In every function I get user data by sharing it from the Contoller.php

In controller.php

public function share_user_data() {
    $user = Auth::user();
    $this->checkValidation($user);
    $this->user = $user;
    View::share('user', $user);
}

public function checkValidation($user){
    if($user->email_activated == 0){
        var_dump($user->email_activated); // I get: int(0)
        return redirect('/verifyEmail');
    }
}

In the other controller

public function viewCategory(Category $category){
    $this->share_user_data(); // here's the check
    $this->get_site_lang();
    $products = $category->products;
    return view('category', compact('category','products'));
}

But I get the category view and not redirected to the verifyEmail route. How to fix this and why it's happening?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire