developeroncall / larateme
增强版的Bootstrap 4 Laravel 模板
Requires
- php: ^7.0
- davejamesmiller/laravel-breadcrumbs: ^5.0
- illuminate/support: 5.*
- laracasts/flash: ^3.0
- marvinlabs/laravel-html-bootstrap-4: ^1.0
README
Laravel Larateme 模板
为您的Laravel应用程序提供全面功能的后台管理面板。
1. 简介
此包在底层依赖于其他包,这些包包括
2. 安装
您可以使用composer命令行安装larateme
,运行以下命令:
composer require developeroncall/larateme
然后运行以下命令将模板资产添加到您的项目中。
php artisan larateme:install
4. 配置
安装后,将发布两个配置文件:`config/larateme.php` 和 `config/breadcrumbs.php`。
<?php
// config/larateme.php
return [
'appearance' => [
'version' => '1.004',
'dashboard' => 1,
/*
* Supported values skin1/skin2/skin3/skin4/skin5/skin6
* To apply blue color - skin1
* To apply orange color - skin2
* To apply cyan color - skin3
* To apply purple color - skin4
* To apply black color - skin5
* To apply gray color - skin6
*
*/
'skin' => 'skin1',
'customizer' => false, // Work in Progress
/*
* The direction of the dashboard.
*/
'dir' => 'ltr',
/*
* The header items that will be rendered.
*/
'header' => [
'right' => [
'larateme::partials.header.block_search',
'larateme::partials.header.languages',
'larateme::partials.header.block_user_profile',
],
'left' => [
'larateme::partials.header.notifications',
'larateme::partials.header.messages',
],
],
/*
* The sidebar items that will be rendered.
*/
'sidebar' => [
'items' => [
'larateme::partials.sidebar.user-panel',
'larateme::partials.sidebar.items',
],
],
/*
* Site Overall Layout
* Supported values are
* 'boxed','dark','horizontal','horizontal-fullwidth','iconbar',
* 'light-sidebar','ltr','mini-sidebar','overlay','rtl',
*/
'layout' => 'light-sidebar',
],
'urls' => [
/*
|--------------------------------------------------------------------------
| URLs
|--------------------------------------------------------------------------
|
| Register here the dashboard main urls, base, logout, login, etc...
| The options that can be nullable is register and password_request meaning that it can be disabled.
|
*/
'base' => '/',
'logout' => 'logout',
'login' => 'login',
'register' => 'register',
'password_request' => 'password/reset',
'password_email' => 'password/email',
'password_reset' => 'password/reset',
'search' => '/search',
],
'images' => [
/*
|--------------------------------------------------------------------------
| IMAGEs
|--------------------------------------------------------------------------
|
| Change the basic images within the template by setting their urls below
|
|
*/
'logo-icon' => '/assets/images/logo-icon.png',
'logo-light-icon' => '/assets/images/logo-light-icon.png',
'logo' => '/assets/images/logo.png',
'logo-dark' => '/assets/images/logo-dark.png',
'logo-light' => '/assets/images/logo-lite.png',
'logo-text' => '/assets/images/logo-text.png',
'logo-light-text' => '/assets/images/logo-lite-text.png',
'login-background' => '/assets/images/big/auth-bg.jpg',
],
'sources' => [
/*
|--------------------------------------------------------------------------
| Data Sources - WORK IN PROGRESS
|--------------------------------------------------------------------------
|
| This is very much a work in progress and should not be used yet
|
*/
'message_list' => [
'klass' => 'MessageController',
'method' => 'messageList',
],
'user_list' => [
'klass' => 'User',
'method' => 'userList',
],
]
有关 `config/breadscrumbs.php` 文件的配置细节,请参阅 Laravel Breadcrumbs 文档。
5. Blade 模板(布局、组件和部分视图)
此包包含一个布局和组件,用于包裹大部分larateme元素。
1. 主要布局
将主要布局视为包含您的内容的容器,这些内容位于larateme头部和侧边栏中。以下是一个使用 `larateme::layout.main` 的示例。
@extends('larateme::layout')
@section('content')
{-- Content--}
@endsection
注意:内容将自动包裹在 `
` 中。2. 页面组件
页面组件是包含内容的容器,包含 `
` 用于持有标题和面包屑,以及 ` ` 用于持有页面内容。示例 @component('larateme::page', ['title' => 'Home', 'sub_title' => 'Main page...', 'breadcrumb' => 'BREADCRUMB_NAME']) The page content... @endcomponent
备注
`sub_title` 和 `breadcrumb` 选项是可选的。
页面组件负责显示 flash 消息。
BREADCRUMB_NAME 是在 `routes/breadcrumbs.php` 文件中定义的面包屑名称。
带有发送数据到面包屑的示例
@component('larateme::page', ['title' => 'Home', 'breadcrumb' => ['home', $user]]) The page content... @endcomponent
3. 卡片组件
卡片组件是Bootstrap卡片的包装。示例代码
@component('larateme::card') You're logged in! @endcomponent
更高级的示例
@component('larateme::card', ['title' => 'Card component', 'card_text' => 'Hello World]) @slot('tools') <button class="btn btn-warning">Button</button> @endslot <p> Box component contents... </p> @slot('footer') <p>Box footer</p> @endslot @endcomponent
注意:支持的样式有
default
、primary
、info
、warning
、success
和danger
。4. 表格盒子组件
表格盒子组件可以用于在larateme盒子组件中直接放置表格。示例用法
@component('larateme::table-box', ['collection' => $users]) <tr> <th>Name</th> <th>Email</th> </tr> @foreach ($users as $user) <tr> <td>{{ $user->name }}</td> <td>{{ $user->email }}</td> </tr> @endforeach @endcomponent
备注
组件将自动渲染分页链接。
您不需要自己处理空集合,如果集合为空,视图将显示有用的消息。
5. 信息盒子
信息盒子组件是Bootstrap信息盒子的包装。示例用法
@include('larateme::info-box', [ 'icon_color' => 'blue', 'icon' => 'thumbs-up', 'text' => 'likes', 'number' => '2000', ])
或者
@include('larateme::info-box', [ 'style' => 'red', 'icon' => 'heart', 'text' => 'loves', 'number' => '500000', 'progress' => 70, 'progress_description' => '70% of the people loved your project!', ])
6. [可选] 覆盖默认视图
您可以自由修改包视图,如果您愿意,可以运行以下命令
php artisan vendor:publish --tag=larateme-views
现在,您可以在 `resources/views/vendor/larateme` 中编辑视图。
注意:如果您发布包视图,它将不会自动使用未来的更新和错误修复。
我会创建自定义元素组件,并在有时间时更新此包。
7. Bootstrap 4 组件 - 在Blade模板中渲染
我已经添加了Bootstrap4 HTML Builder,这使得生成标准的Bootstrap组件变得简单。
这是一个标准的Jumbotron元素
@component('bs::jumbotron') @slot('heading') Hello, world! @endslot @slot('subheading') This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information. @endslot <hr class="my-3"> <p>It uses utility classes for typography and spacing to space content out within the larger container.</p> @slot('actions') {!! bs()->a('#', 'Learn more')->asButton('primary') !!} @endslot @endcomponent有关使用此包的详细信息,请访问文档