Skip to content

Commit

Permalink
enhanced url config values & more (#410)
Browse files Browse the repository at this point in the history
* fixed main_views copy and added load fallback

* enhanced url setting
- added missing url config entries
- added ability to use routes instead of url
- added ability to override url settings via blade files
- updated README.md with new config options

* added ability to add `id`-attributes to menu items
  • Loading branch information
REJack authored and resslinger committed Nov 6, 2019
1 parent 533697d commit d56e4e5
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 22 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ The following config options available:

### 6.7 URLs
Here we have the url settings to setup the correct login/register link. Register here your dashboard, logout, login and register URLs.
- __`use_route_url`__

Whether to use `route()` instead of `url()`.
- __`dashboard_url`__

Changes the dashboard/logo URL.
Expand All @@ -440,6 +443,12 @@ Here we have the url settings to setup the correct login/register link. Register
- __`register_url`__

Changes the register link or if set `false` it will hide.
- __`password_reset_url`__

Changes the password reset url.
- __`password_email_url`__

Changes the password email url.


### 6.8 Laravel Mix
Expand Down
6 changes: 6 additions & 0 deletions config/adminlte.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
|
*/

'use_route_url' => false,

'dashboard_url' => 'home',

'logout_url' => 'logout',
Expand All @@ -140,6 +142,10 @@

'register_url' => 'register',

'password_reset_url' => 'password/reset',

'password_email_url' => 'password/email',

/*
|--------------------------------------------------------------------------
| Laravel Mix
Expand Down
27 changes: 22 additions & 5 deletions resources/views/login.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,32 @@

@section('classes_body', 'login-page')

@php( $login_url = View::getSection('login_url') ?? config('adminlte.login_url', 'login') )
@php( $register_url = View::getSection('register_url') ?? config('adminlte.register_url', 'register') )
@php( $password_reset_url = View::getSection('password_reset_url') ?? config('adminlte.password_reset_url', 'password/reset') )
@php( $dashboard_url = View::getSection('dashboard_url') ?? config('adminlte.dashboard_url', 'home') )

@if (config('adminlte.use_route_url', false))
@php( $login_url = $login_url ?? route($login_url) )
@php( $register_url = $register_url ?? route($register_url) )
@php( $password_reset_url = $password_reset_url ?? route($password_reset_url) )
@php( $dashboard_url = $dashboard_url ?? route($dashboard_url) )
@else
@php( $login_url = $login_url ?? url($login_url) )
@php( $register_url = $register_url ?? url($register_url) )
@php( $password_reset_url = $password_reset_url ?? url($password_reset_url) )
@php( $dashboard_url = $dashboard_url ?? url($dashboard_url) )
@endif

@section('body')
<div class="login-box">
<div class="login-logo">
<a href="{{ url(config('adminlte.dashboard_url', 'home')) }}">{!! config('adminlte.logo', '<b>Admin</b>LTE') !!}</a>
<a href="{{ $dashboard_url }}">{!! config('adminlte.logo', '<b>Admin</b>LTE') !!}</a>
</div>
<div class="card">
<div class="card-body login-card-body">
<p class="login-box-msg">{{ __('adminlte::adminlte.login_message') }}</p>
<form action="{{ url(config('adminlte.login_url', 'login')) }}" method="post">
<form action="{{ $login_url }}" method="post">
{{ csrf_field() }}
<div class="input-group mb-3">
<input type="email" name="email" class="form-control {{ $errors->has('email') ? 'is-invalid' : '' }}" value="{{ old('email') }}" placeholder="{{ __('adminlte::adminlte.email') }}">
Expand Down Expand Up @@ -58,13 +75,13 @@
</div>
</form>
<p class="mt-2 mb-1">
<a href="{{ url(config('adminlte.password_reset_url', 'password/reset')) }}">
<a href="{{ $password_reset_url }}">
{{ __('adminlte::adminlte.i_forgot_my_password') }}
</a>
</p>
@if (config('adminlte.register_url', 'register'))
@if ($register_url)
<p class="mb-0">
<a href="{{ url(config('adminlte.register_url', 'register')) }}">
<a href="{{ $register_url }}">
{{ __('adminlte::adminlte.register_a_new_membership') }}
</a>
</p>
Expand Down
21 changes: 16 additions & 5 deletions resources/views/page.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,29 @@
@section('body_data',
(config('adminlte.sidebar_scrollbar_theme', 'os-theme-light') != 'os-theme-light' ? 'data-scrollbar-theme=' . config('adminlte.sidebar_scrollbar_theme') : '') . ' ' . (config('adminlte.sidebar_scrollbar_auto_hide', 'l') != 'l' ? 'data-scrollbar-auto-hide=' . config('adminlte.sidebar_scrollbar_auto_hide') : ''))

@php( $logout_url = View::getSection('logout_url') ?? config('adminlte.logout_url', 'logout') )
@php( $dashboard_url = View::getSection('dashboard_url') ?? config('adminlte.dashboard_url', 'home') )

@if (config('adminlte.use_route_url', false))
@php( $logout_url = $logout_url ?? route($logout_url) )
@php( $dashboard_url = $dashboard_url ?? route($dashboard_url) )
@else
@php( $logout_url = $logout_url ?? url($logout_url) )
@php( $dashboard_url = $dashboard_url ?? url($dashboard_url) )
@endif

@section('body')
<div class="wrapper">
@if(config('adminlte.layout_topnav') || View::getSection('layout_topnav'))
<nav class="main-header navbar {{config('adminlte.classes_topnav_nav', 'navbar-expand-md')}} {{config('adminlte.topnav_color', 'navbar-white navbar-light')}}">
<div class="{{config('adminlte.classes_topnav_container', 'container')}}">
@if(config('adminlte.logo_img_xl'))
<a href="{{ url(config('adminlte.dashboard_url', 'home')) }}" class="navbar-brand logo-switch">
<a href="{{ $dashboard_url }}" class="navbar-brand logo-switch">
<img src="{{ asset(config('adminlte.logo_img', 'vendor/adminlte/dist/img/AdminLTELogo.png')) }}" alt="{{config('adminlte.logo_img_alt', 'AdminLTE')}}" class="{{config('adminlte.logo_img_class', 'brand-image-xl')}} logo-xs">
<img src="{{ asset(config('adminlte.logo_img_xl')) }}" alt="{{config('adminlte.logo_img_alt', 'AdminLTE')}}" class="{{config('adminlte.logo_img_xl_class', 'brand-image-xs')}} logo-xl">
</a>
@else
<a href="{{ url(config('adminlte.dashboard_url', 'home')) }}" class="navbar-brand {{ config('adminlte.classes_brand') }}">
<a href="{{ $dashboard_url }}" class="navbar-brand {{ config('adminlte.classes_brand') }}">
<img src="{{ asset(config('adminlte.logo_img', 'vendor/adminlte/dist/img/AdminLTELogo.png')) }}" alt="{{config('adminlte.logo_img_alt', 'AdminLTE')}}" class="brand-image img-circle elevation-3" style="opacity: .8">
<span class="brand-text font-weight-light {{ config('adminlte.classes_brand_text') }}">
{!! config('adminlte.logo', '<b>Admin</b>LTE') !!}
Expand Down Expand Up @@ -91,7 +102,7 @@
>
<i class="fa fa-fw fa-power-off"></i> {{ __('adminlte::adminlte.log_out') }}
</a>
<form id="logout-form" action="{{ url(config('adminlte.logout_url', 'auth/logout')) }}" method="POST" style="display: none;">
<form id="logout-form" action="{{ $logout_url }}" method="POST" style="display: none;">
@if(config('adminlte.logout_method'))
{{ method_field(config('adminlte.logout_method')) }}
@endif
Expand All @@ -114,12 +125,12 @@
@if(!config('adminlte.layout_topnav') && !View::getSection('layout_topnav'))
<aside class="main-sidebar {{config('adminlte.classes_sidebar', 'sidebar-dark-primary elevation-4')}}">
@if(config('adminlte.logo_img_xl'))
<a href="{{ url(config('adminlte.dashboard_url', 'home')) }}" class="brand-link logo-switch">
<a href="{{ $dashboard_url }}" class="brand-link logo-switch">
<img src="{{ asset(config('adminlte.logo_img', 'vendor/adminlte/dist/img/AdminLTELogo.png')) }}" alt="{{config('adminlte.logo_img_alt', 'AdminLTE')}}" class="{{config('adminlte.logo_img_class', 'brand-image-xl')}} logo-xs">
<img src="{{ asset(config('adminlte.logo_img_xl')) }}" alt="{{config('adminlte.logo_img_alt', 'AdminLTE')}}" class="{{config('adminlte.logo_img_xl_class', 'brand-image-xs')}} logo-xl">
</a>
@else
<a href="{{ url(config('adminlte.dashboard_url', 'home')) }}" class="brand-link {{ config('adminlte.classes_brand') }}">
<a href="{{ $dashboard_url }}" class="brand-link {{ config('adminlte.classes_brand') }}">
<img src="{{ asset(config('adminlte.logo_img', 'vendor/adminlte/dist/img/AdminLTELogo.png')) }}" alt="{{config('adminlte.logo_img_alt', 'AdminLTE')}}" class="brand-image img-circle elevation-3" style="opacity: .8">
<span class="brand-text font-weight-light {{ config('adminlte.classes_brand_text') }}">
{!! config('adminlte.logo', '<b>Admin</b>LTE') !!}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/partials/menu-item-sub-top-nav.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@if (is_array($item))
<li class="@if (isset($item['submenu']))dropdown-submenu @endif">
<li @if (isset($item['id'])) id="{{ $item['id'] }}" @endif class="@if (isset($item['submenu']))dropdown-submenu @endif">
<a class="dropdown-item @if (isset($item['submenu']))dropdown-toggle @endif" href="{{ $item['href'] }}"
@if (isset($item['submenu'])) data-toggle="dropdown" @endif
@if (isset($item['target'])) target="{{ $item['target'] }}" @endif
Expand Down
2 changes: 1 addition & 1 deletion resources/views/partials/menu-item-top-nav.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
</form>
@elseif (is_array($item))
<li class="nav-item {{ $item['top_nav_class'] }}">
<li @if (isset($item['id'])) id="{{ $item['id'] }}" @endif class="nav-item {{ $item['top_nav_class'] }}">
<a class="nav-link @if (isset($item['submenu']))dropdown-item dropdown-toggle @endif" href="{{ $item['href'] }}"
@if (isset($item['submenu'])) data-toggle="dropdown" @endif
@if (isset($item['target'])) target="{{ $item['target'] }}" @endif
Expand Down
8 changes: 4 additions & 4 deletions resources/views/partials/menu-item.blade.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@if (!isset($item['topnav']) || (isset($item['topnav']) && !$item['topnav']))
@if (is_string($item))
<li class="nav-header">{{ $item }}</li>
<li @if (isset($item['id'])) id="{{ $item['id'] }}" @endif class="nav-header">{{ $item }}</li>
@elseif (isset($item['header']))
<li class="nav-header">{{ $item['header'] }}</li>
<li @if (isset($item['id'])) id="{{ $item['id'] }}" @endif class="nav-header">{{ $item['header'] }}</li>
@elseif (isset($item['search']) && $item['search'])
<li>
<li @if (isset($item['id'])) id="{{ $item['id'] }}" @endif>
<form action="{{ $item['href'] }}" method="{{ $item['method'] }}" class="form-inline">
<div class="input-group">
<input class="form-control form-control-sidebar" type="search" name="{{ $item['input_name'] }}" placeholder="{{ $item['text'] }}" aria-label="{{ $item['aria-label'] ?? $item['text'] }}">
Expand All @@ -17,7 +17,7 @@
</form>
</li>
@else
<li class="nav-item @if (isset($item['submenu'])){{ $item['submenu_class'] }}@endif">
<li @if (isset($item['id'])) id="{{ $item['id'] }}" @endif class="nav-item @if (isset($item['submenu'])){{ $item['submenu_class'] }}@endif">
<a class="nav-link {{ $item['class'] }}" href="{{ $item['href'] }}"
@if (isset($item['target'])) target="{{ $item['target'] }}" @endif
>
Expand Down
15 changes: 13 additions & 2 deletions resources/views/passwords/confirm.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@

@section('classes_body', 'lockscreen')

@php( $password_reset_url = View::getSection('password_reset_url') ?? config('adminlte.password_reset_url', 'password/reset') )
@php( $dashboard_url = View::getSection('dashboard_url') ?? config('adminlte.dashboard_url', 'home') )

@if (config('adminlte.use_route_url', false))
@php( $password_reset_url = $password_reset_url ?? route($password_reset_url) )
@php( $dashboard_url = $dashboard_url ?? route($dashboard_url) )
@else
@php( $password_reset_url = $register_url ?? url($password_reset_url) )
@php( $dashboard_url = $register_url ?? url($dashboard_url) )
@endif

@section('body')
<div class="lockscreen-wrapper">
<div class="lockscreen-logo">
<a href="{{ url(config('adminlte.dashboard_url', 'home')) }}">{!! config('adminlte.logo', '<b>Admin</b>LTE') !!}</a>
<a href="{{ $dashboard_url }}">{!! config('adminlte.logo', '<b>Admin</b>LTE') !!}</a>
</div>

<div class="lockscreen-name">{{{ isset(Auth::user()->name) ? Auth::user()->name : Auth::user()->email }}}</div>
Expand All @@ -35,7 +46,7 @@
{{ __('adminlte::adminlte.confirm_password_message') }}
</div>
<div class="text-center">
<a href="{{ url(config('adminlte.password_reset_url', 'password/reset')) }}">
<a href="{{ $password_reset_url }}">
{{ __('adminlte::adminlte.i_forgot_my_password') }}
</a>
</div>
Expand Down
15 changes: 13 additions & 2 deletions resources/views/passwords/email.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@

@section('classes_body', 'login-page')

@php( $password_email_url = View::getSection('password_email_url') ?? config('adminlte.password_email_url', 'password/email') )
@php( $dashboard_url = View::getSection('dashboard_url') ?? config('adminlte.dashboard_url', 'home') )

@if (config('adminlte.use_route_url', false))
@php( $password_email_url = $password_email_url ?? route($password_email_url) )
@php( $dashboard_url = $dashboard_url ?? route($dashboard_url) )
@else
@php( $password_email_url = $password_email_url ?? url($password_email_url) )
@php( $dashboard_url = $dashboard_url ?? url($dashboard_url) )
@endif

@section('body')
<div class="login-box">
<div class="login-logo">
<a href="{{ url(config('adminlte.dashboard_url', 'home')) }}">{!! config('adminlte.logo', '<b>Admin</b>LTE') !!}</a>
<a href="{{ $dashboard_url }}">{!! config('adminlte.logo', '<b>Admin</b>LTE') !!}</a>
</div>
<div class="card">
<div class="card-body login-card-body">
Expand All @@ -19,7 +30,7 @@
{{ session('status') }}
</div>
@endif
<form action="{{ url(config('adminlte.password_email_url', 'password/email')) }}" method="post">
<form action="{{ $password_email_url }}" method="post">
{{ csrf_field() }}
<div class="input-group mb-3">
<input type="email" name="email" class="form-control {{ $errors->has('email') ? 'is-invalid' : '' }}" value="{{ old('email') }}" placeholder="{{ __('adminlte::adminlte.email') }}">
Expand Down
15 changes: 13 additions & 2 deletions resources/views/passwords/reset.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,26 @@

@section('classes_body', 'login-page')

@php( $password_reset_url = View::getSection('password_reset_url') ?? config('adminlte.password_reset_url', 'password/reset') )
@php( $dashboard_url = View::getSection('dashboard_url') ?? config('adminlte.dashboard_url', 'home') )

@if (config('adminlte.use_route_url', false))
@php( $password_reset_url = $password_reset_url ?? route($password_reset_url) )
@php( $dashboard_url = $dashboard_url ?? route($dashboard_url) )
@else
@php( $password_reset_url = $password_reset_url ?? url($password_reset_url) )
@php( $dashboard_url = $dashboard_url ?? url($dashboard_url) )
@endif

@section('body')
<div class="login-box">
<div class="login-logo">
<a href="{{ url(config('adminlte.dashboard_url', 'home')) }}">{!! config('adminlte.logo', '<b>Admin</b>LTE') !!}</a>
<a href="{{ $dashboard_url }}">{!! config('adminlte.logo', '<b>Admin</b>LTE') !!}</a>
</div>
<div class="card">
<div class="card-body login-card-body">
<p class="login-box-msg">{{ trans('adminlte::adminlte.password_reset_message') }}</p>
<form action="{{ url(config('adminlte.password_reset_url', 'password/reset')) }}" method="post">
<form action="{{ $password_reset_url }}" method="post">
{{ csrf_field() }}
<input type="hidden" name="token" value="{{ $token }}">
<div class="input-group mb-3">
Expand Down

0 comments on commit d56e4e5

Please sign in to comment.