1 month ago

Why does {{ Auth::user() }} work anywhere but other models don't?

Posted 1 month ago by mrkarma4ya

How come {{ Auth::user() }} works anywhere but any other model I need to import with the 'use' command?

I want to display a list of categories in all my pages, but I keep getting 'Class 'Category' not found'. I'm trying this right now:

@foreach (Category::orderBy('name', 'asc') as $category )
        <li><a href="#">{{ $category->name }}</a></li>

Can I make Categories model universally accessible like Auth? Or this there a better way to do this?

Please sign in or create an account to participate in this conversation.