Skip to content

Commit bd693a5

Browse files
committed
Changes and fixes to adapt to 5.3 code style.
* Logout uses POST method to log user out * Routes are prefixed * Small fixes to login redirects
1 parent a151cc4 commit bd693a5

File tree

10 files changed

+41
-24
lines changed

10 files changed

+41
-24
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
"email": "[email protected]"
1313
}
1414
],
15-
"version": "2.0.0",
15+
"version": "2.0.1",
1616
"require": {
17+
"laravel/framework": "5.3.*",
1718
"laravelcollective/html": "^5.3",
1819
"intervention/image": "^2.3",
1920
"yajra/laravel-datatables-oracle": "^6.18"

src/Controllers/publish/LoginController

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,14 @@ class LoginController extends Controller
2020

2121
use AuthenticatesUsers;
2222

23-
/**
24-
* Where to redirect users after login / registration.
25-
*
26-
* @var string
27-
*/
28-
protected $redirectTo = '/home';
29-
3023
/**
3124
* Create a new controller instance.
3225
*
3326
* @return void
3427
*/
3528
public function __construct()
3629
{
30+
$this->redirectTo = config('quickadmin.route');
3731
$this->middleware('guest', ['except' => 'logout']);
3832
}
3933
}

src/Public/quickadmin/css/quickadmin-layout.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3102,3 +3102,22 @@ table {
31023102
padding: 10px 5px;
31033103
margin-bottom: 5px;
31043104
}
3105+
3106+
.logout {
3107+
padding: 10px 15px;
3108+
border: none;
3109+
border-top: 1px solid #484848;
3110+
color: #d9d9d9;
3111+
background: transparent;
3112+
width: 100%;
3113+
text-align: left;
3114+
font-size: 14px;
3115+
font-weight: 300;
3116+
}
3117+
3118+
.logout > i {
3119+
font-size: 16px;
3120+
margin-right: 5px;
3121+
text-shadow: none;
3122+
color: #888888;
3123+
}

src/Templates/controller

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class $CLASS$ extends Controller {
5050
$FILESAVING$
5151
$MODEL$::create($request->all());
5252

53-
return redirect()->route('$COLLECTION$.index');
53+
return redirect()->route(config('quickadmin.route').'.$COLLECTION$.index');
5454
}
5555

5656
/**
@@ -81,7 +81,7 @@ class $CLASS$ extends Controller {
8181

8282
$$RESOURCE$->update($request->all());
8383

84-
return redirect()->route('$COLLECTION$.index');
84+
return redirect()->route(config('quickadmin.route').'.$COLLECTION$.index');
8585
}
8686

8787
/**
@@ -93,7 +93,7 @@ class $CLASS$ extends Controller {
9393
{
9494
$MODEL$::destroy($id);
9595

96-
return redirect()->route('$COLLECTION$.index');
96+
return redirect()->route(config('quickadmin.route').'.$COLLECTION$.index');
9797
}
9898

9999
/**
@@ -111,7 +111,7 @@ class $CLASS$ extends Controller {
111111
$MODEL$::whereNotNull('id')->delete();
112112
}
113113

114-
return redirect()->route('$COLLECTION$.index');
114+
return redirect()->route(config('quickadmin.route').'.$COLLECTION$.index');
115115
}
116116

117117
}

src/Templates/view_create

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</div>
1717
</div>
1818

19-
{!! Form::open(array($FILES$'route' => '$ROUTE$.store', 'id' => 'form-with-validation', 'class' => 'form-horizontal')) !!}
19+
{!! Form::open(array($FILES$'route' => config('quickadmin.route').'.$ROUTE$.store', 'id' => 'form-with-validation', 'class' => 'form-horizontal')) !!}
2020

2121
$FORMFIELDS$
2222

src/Templates/view_edit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
</div>
1717
</div>
1818

19-
{!! Form::model($$MODEL$, array($FILES$'class' => 'form-horizontal', 'id' => 'form-with-validation', 'method' => 'PATCH', 'route' => array('$ROUTE$.update', $$RESOURCE$->id))) !!}
19+
{!! Form::model($$MODEL$, array($FILES$'class' => 'form-horizontal', 'id' => 'form-with-validation', 'method' => 'PATCH', 'route' => array(config('quickadmin.route').'.$ROUTE$.update', $$RESOURCE$->id))) !!}
2020

2121
$FORMFIELDS$
2222

2323
<div class="form-group">
2424
<div class="col-sm-10 col-sm-offset-2">
2525
{!! Form::submit(trans('quickadmin::templates.templates-view_edit-update'), array('class' => 'btn btn-primary')) !!}
26-
{!! link_to_route('$ROUTE$.index', trans('quickadmin::templates.templates-view_edit-cancel'), null, array('class' => 'btn btn-default')) !!}
26+
{!! link_to_route(config('quickadmin.route').'.$ROUTE$.index', trans('quickadmin::templates.templates-view_edit-cancel'), null, array('class' => 'btn btn-default')) !!}
2727
</div>
2828
</div>
2929

src/Templates/view_index

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
@section('content')
44

5-
<p>{!! link_to_route('$ROUTE$.create', trans('quickadmin::templates.templates-view_index-add_new') , null, array('class' => 'btn btn-success')) !!}</p>
5+
<p>{!! link_to_route(config('quickadmin.route').'.$ROUTE$.create', trans('quickadmin::templates.templates-view_index-add_new') , null, array('class' => 'btn btn-success')) !!}</p>
66

77
@if ($$RESOURCE$->count())
88
<div class="portlet box green">
@@ -29,8 +29,8 @@
2929
</td>
3030
$FIELDS$
3131
<td>
32-
{!! link_to_route('$ROUTE$.edit', trans('quickadmin::templates.templates-view_index-edit'), array($row->id), array('class' => 'btn btn-xs btn-info')) !!}
33-
{!! Form::open(array('style' => 'display: inline-block;', 'method' => 'DELETE', 'onsubmit' => "return confirm('".trans("quickadmin::templates.templates-view_index-are_you_sure")."');", 'route' => array('$ROUTE$.destroy', $row->id))) !!}
32+
{!! link_to_route(config('quickadmin.route').'.$ROUTE$.edit', trans('quickadmin::templates.templates-view_index-edit'), array($row->id), array('class' => 'btn btn-xs btn-info')) !!}
33+
{!! Form::open(array('style' => 'display: inline-block;', 'method' => 'DELETE', 'onsubmit' => "return confirm('".trans("quickadmin::templates.templates-view_index-are_you_sure")."');", 'route' => array(config('quickadmin.route').'.$ROUTE$.destroy', $row->id))) !!}
3434
{!! Form::submit(trans('quickadmin::templates.templates-view_index-delete'), array('class' => 'btn btn-xs btn-danger')) !!}
3535
{!! Form::close() !!}
3636
</td>
@@ -45,7 +45,7 @@
4545
</button>
4646
</div>
4747
</div>
48-
{!! Form::open(['route' => '$ROUTE$.massDelete', 'method' => 'post', 'id' => 'massDelete']) !!}
48+
{!! Form::open(['route' => config('quickadmin.route').'.$ROUTE$.massDelete', 'method' => 'post', 'id' => 'massDelete']) !!}
4949
<input type="hidden" id="send" name="toDelete">
5050
{!! Form::close() !!}
5151
</div>

src/Traits/AdminPermissionsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private function parseData($request)
3939
if (in_array($route[0], $official)) {
4040
return [$role, config('quickadmin.defaultRole')];
4141
} else {
42-
$menuName = $route[0];
42+
$menuName = $route[1];
4343
}
4444
$menu = Menu::where('name', ucfirst($menuName))->firstOrFail();
4545

src/Views/admin/partials/sidebar.blade.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
@if($menu->menu_type != 2 && is_null($menu->parent_id))
3535
@if(Auth::user()->role->canAccessMenu($menu))
3636
<li @if(isset(explode('/',Request::path())[1]) && explode('/',Request::path())[1] == strtolower($menu->name)) class="active" @endif>
37-
<a href="{{ route(strtolower($menu->name).'.index') }}">
37+
<a href="{{ route(config('quickadmin.route').'.'.strtolower($menu->name).'.index') }}">
3838
<i class="fa {{ $menu->icon }}"></i>
3939
<span class="title">{{ $menu->title }}</span>
4040
</a>
@@ -53,7 +53,7 @@
5353
@if(Auth::user()->role->canAccessMenu($child))
5454
<li
5555
@if(isset(explode('/',Request::path())[1]) && explode('/',Request::path())[1] == strtolower($child->name)) class="active active-sub" @endif>
56-
<a href="{{ route(strtolower($child->name).'.index') }}">
56+
<a href="{{ route(strtolower(config('quickadmin.route').'.'.$child->name).'.index') }}">
5757
<i class="fa {{ $child->icon }}"></i>
5858
<span class="title">
5959
{{ $child->title }}
@@ -68,10 +68,12 @@
6868
@endif
6969
@endforeach
7070
<li>
71-
<a href="{{ url('logout') }}">
71+
{!! Form::open(['url' => 'logout']) !!}
72+
<button type="submit" class="logout">
7273
<i class="fa fa-sign-out fa-fw"></i>
7374
<span class="title">{{ trans('quickadmin::admin.partials-sidebar-logout') }}</span>
74-
</a>
75+
</button>
76+
{!! Form::close() !!}
7577
</li>
7678
</ul>
7779
</div>

src/routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Route::group([
1515
'middleware' => ['web', 'auth', 'role'],
1616
'prefix' => config('quickadmin.route'),
17+
'as' => config('quickadmin.route'),
1718
'namespace' => 'App\Http\Controllers',
1819
], function () use ($menus) {
1920
foreach ($menus as $menu) {

0 commit comments

Comments
 (0)