jeudi 16 mai 2019

Using view share in blade

When displaying the code on view it gives an error . Which is:

Undefined variable: noti_count (View: C:\laravel\Procure\resources\views\layouts\user.blade.php)

I'm not yet used to use view share in controller . Need some guidance:

public function __construct()
{
    if (Auth::check())
    {
        if (Auth::User()->role == "Normal User")
        {       
            $noti_count = Notification
                              ::where('receive_id','=',Auth::user()->id)
                              ->count();

            view()->share('noti_count', $noti_count);

        }
        else if (Auth::User()->role == "PWD")
        {
            # code...
        }
        elseif (Auth::User()->role == "Senior Citizen")
        {
            # code...
        }
        else
        {       

        }    
    }    
}

Blade view code

<span class="badge badge-danger badge-counter">{!! $noti_count !!}+</span>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire