简体   繁体   English

laravel 9 在管理面板中创建侧边栏

[英]laravel 9 create sidebar in admin panel

I would like to make a dashboard for the administrator.我想为管理员制作一个仪表板。 I have seen several tutorials but they are all either you have to integrate a package or a template.我看过几个教程,但它们都是您必须集成 package 或模板。 I am trying to make an admin dashboard from scratch by myself.我正在尝试自己从头开始制作管理仪表板。

Admin home.blade.php管理员 home.blade.php

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
                <div class="panel-heading">Super Admin Dashboard</div>
                <div class="panel-body">
                    @if (session('status'))
                        <div class="alert alert-success">
                            {{ session('status') }}
                        </div>
                    @endif
                        This is Admin Dashboard. You must be super privileged to be here !
               
                        @auth
                            @if(Auth::user()->hasRole('ROLE_SUPERADMIN'))
                                <li class="nav-item">
                                    <a class="nav-link" href="{{ route('superadmin') }}">Dashboard</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" href="{{ route('categories.index') }}">Categories</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" href="{{ route('subcategories.index') }}">SubCategories</a>
                                </li>
                            @endif
                        @endauth
                    </div>
            </div>
        </div>
    </div>
</div>
@endsection 

I'm trying to make a sidebar in bootstrap 5 and laravel 9 but I can't.我正在尝试在 bootstrap 5 和 laravel 9 中制作侧边栏,但我做不到。 When I remove the @extends at the top, the page shows up in white.当我删除顶部的@extends 时,页面显示为白色。 But I would like to remove this navbar in the dashboard and make a vertical navbar by myself Categories SubCategories I would like the navbar on the left to make a dropdown design and put the categories and subcategories in this dropdown, what should I do if I can't delete the extends with the layout?但是我想把dashboard里面的这个navbar去掉,自己做一个垂直的navbar Categories SubCategories 我想让左边的navbar做一个下拉设计,把类别和子类别放到这个下拉里面,如果可以怎么办'删除布局的扩展? can someone give me the answer to this problem?有人可以给我这个问题的答案吗?

You can pass parameters to @extend您可以将参数传递给@extend

@extends('layouts.app', ['navbar' => false])

@section('content')
{{-- Your content --}}
@endsection

And in your layouts.app在你的layouts.app


@if(!isset($navbar) || $navbar)
<nav>
{{-- Your navbar code --}}
</nav>
@endif

You can separate Navbar from Sidebar in different files components and use it whenever you want您可以在不同的文件组件中将导航栏与侧边栏分开,并随时使用它

https://laravel.com/docs/8.x/blade#components https://laravel.com/docs/8.x/blade#components

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM