Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

顶部分类应该最后改成动态的 #14

Open
luanjinlong opened this issue Mar 7, 2018 · 0 comments
Open

顶部分类应该最后改成动态的 #14

luanjinlong opened this issue Mar 7, 2018 · 0 comments

Comments

@luanjinlong
Copy link

app/Providers/AppServiceProvider.php:

public function boot()
	{

        $view_categories = App\Models\Category::all();
        \View::share('view_categories',$view_categories);
    }

resources/views/layouts/_header.blade.php

<ul class="nav navbar-nav">
                    <li class="{{ active_class(if_route('topics.index')) }}"><a href="{{ route('topics.index') }}">话题</a></li>
                    @foreach($view_categories as $view_category)
                    <li class="{{ active_class((if_route('categories.show') && if_route_param('category', $view_category->id ))) }}"><a href="{{ route('categories.show', $view_category->id) }}">{{ $view_category->name }}</a></li>
                    @endforeach
                </ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant