加入body class至html,自動帶入目前的路由名稱及語系
This commit is contained in:
parent
a90b5d19e8
commit
0d99af2fef
23
app/Presenters/BodyClassPresenter.php
Normal file
23
app/Presenters/BodyClassPresenter.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Presenters;
|
||||
|
||||
use Route;
|
||||
|
||||
class BodyClassPresenter
|
||||
{
|
||||
public function getRouteName()
|
||||
{
|
||||
return str_replace('.', '-', Route::currentRouteName());
|
||||
}
|
||||
|
||||
public function print()
|
||||
{
|
||||
$classes =
|
||||
[
|
||||
$this->getRouteName(),
|
||||
'lang-' . app()->getLocale()
|
||||
];
|
||||
return implode(' ', $classes);
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,8 @@
|
||||
@show
|
||||
@stack('admin-app-styles')
|
||||
</head>
|
||||
<body class="app admin-area sidebar-lg-show header-fixed sidebar-fixed aside-menu-fixed footer-fixed">
|
||||
@inject('bodyClassPresenter', App\Presenters\BodyClassPresenter)
|
||||
<body class="app admin-area sidebar-lg-show header-fixed sidebar-fixed aside-menu-fixed footer-fixed {{ $bodyClassPresenter->print() }}">
|
||||
<header id="app-header" class="app-header navbar">
|
||||
<button class="navbar-toggler sidebar-toggler d-lg-none mr-auto" type="button" data-toggle="sidebar-show">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
|
||||
@ -17,7 +17,8 @@
|
||||
@show
|
||||
@stack('app-styles')
|
||||
</head>
|
||||
<body>
|
||||
@inject('bodyClassPresenter', App\Presenters\BodyClassPresenter)
|
||||
<body class="{{ $bodyClassPresenter->print() }}">
|
||||
@section('content-header')
|
||||
@include('components.nav')
|
||||
@show
|
||||
|
||||
Loading…
Reference in New Issue
Block a user