Skip to content

Commit

Permalink
Changes and fixes to adapt to 5.3 code style.
Browse files Browse the repository at this point in the history
* Logout uses POST method to log user out
* Routes are prefixed
* Small fixes to login redirects
  • Loading branch information
ModestasV committed Sep 8, 2016
1 parent a151cc4 commit bd693a5
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 24 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"email": "[email protected]"
}
],
"version": "2.0.0",
"version": "2.0.1",
"require": {
"laravel/framework": "5.3.*",
"laravelcollective/html": "^5.3",
"intervention/image": "^2.3",
"yajra/laravel-datatables-oracle": "^6.18"
Expand Down
8 changes: 1 addition & 7 deletions src/Controllers/publish/LoginController
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,14 @@ class LoginController extends Controller

use AuthenticatesUsers;

/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/home';

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->redirectTo = config('quickadmin.route');
$this->middleware('guest', ['except' => 'logout']);
}
}
19 changes: 19 additions & 0 deletions src/Public/quickadmin/css/quickadmin-layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -3102,3 +3102,22 @@ table {
padding: 10px 5px;
margin-bottom: 5px;
}

.logout {
padding: 10px 15px;
border: none;
border-top: 1px solid #484848;
color: #d9d9d9;
background: transparent;
width: 100%;
text-align: left;
font-size: 14px;
font-weight: 300;
}

.logout > i {
font-size: 16px;
margin-right: 5px;
text-shadow: none;
color: #888888;
}
8 changes: 4 additions & 4 deletions src/Templates/controller
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class $CLASS$ extends Controller {
$FILESAVING$
$MODEL$::create($request->all());

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

/**
Expand Down Expand Up @@ -81,7 +81,7 @@ class $CLASS$ extends Controller {

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

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

/**
Expand All @@ -93,7 +93,7 @@ class $CLASS$ extends Controller {
{
$MODEL$::destroy($id);

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

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

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

}
2 changes: 1 addition & 1 deletion src/Templates/view_create
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
</div>

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

$FORMFIELDS$

Expand Down
4 changes: 2 additions & 2 deletions src/Templates/view_edit
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
</div>
</div>

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

$FORMFIELDS$

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

Expand Down
8 changes: 4 additions & 4 deletions src/Templates/view_index
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@section('content')

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

@if ($$RESOURCE$->count())
<div class="portlet box green">
Expand All @@ -29,8 +29,8 @@
</td>
$FIELDS$
<td>
{!! link_to_route('$ROUTE$.edit', trans('quickadmin::templates.templates-view_index-edit'), array($row->id), array('class' => 'btn btn-xs btn-info')) !!}
{!! 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))) !!}
{!! 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')) !!}
{!! 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))) !!}
{!! Form::submit(trans('quickadmin::templates.templates-view_index-delete'), array('class' => 'btn btn-xs btn-danger')) !!}
{!! Form::close() !!}
</td>
Expand All @@ -45,7 +45,7 @@
</button>
</div>
</div>
{!! Form::open(['route' => '$ROUTE$.massDelete', 'method' => 'post', 'id' => 'massDelete']) !!}
{!! Form::open(['route' => config('quickadmin.route').'.$ROUTE$.massDelete', 'method' => 'post', 'id' => 'massDelete']) !!}
<input type="hidden" id="send" name="toDelete">
{!! Form::close() !!}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/AdminPermissionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private function parseData($request)
if (in_array($route[0], $official)) {
return [$role, config('quickadmin.defaultRole')];
} else {
$menuName = $route[0];
$menuName = $route[1];
}
$menu = Menu::where('name', ucfirst($menuName))->firstOrFail();

Expand Down
10 changes: 6 additions & 4 deletions src/Views/admin/partials/sidebar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@if($menu->menu_type != 2 && is_null($menu->parent_id))
@if(Auth::user()->role->canAccessMenu($menu))
<li @if(isset(explode('/',Request::path())[1]) && explode('/',Request::path())[1] == strtolower($menu->name)) class="active" @endif>
<a href="{{ route(strtolower($menu->name).'.index') }}">
<a href="{{ route(config('quickadmin.route').'.'.strtolower($menu->name).'.index') }}">
<i class="fa {{ $menu->icon }}"></i>
<span class="title">{{ $menu->title }}</span>
</a>
Expand All @@ -53,7 +53,7 @@
@if(Auth::user()->role->canAccessMenu($child))
<li
@if(isset(explode('/',Request::path())[1]) && explode('/',Request::path())[1] == strtolower($child->name)) class="active active-sub" @endif>
<a href="{{ route(strtolower($child->name).'.index') }}">
<a href="{{ route(strtolower(config('quickadmin.route').'.'.$child->name).'.index') }}">
<i class="fa {{ $child->icon }}"></i>
<span class="title">
{{ $child->title }}
Expand All @@ -68,10 +68,12 @@
@endif
@endforeach
<li>
<a href="{{ url('logout') }}">
{!! Form::open(['url' => 'logout']) !!}
<button type="submit" class="logout">
<i class="fa fa-sign-out fa-fw"></i>
<span class="title">{{ trans('quickadmin::admin.partials-sidebar-logout') }}</span>
</a>
</button>
{!! Form::close() !!}
</li>
</ul>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Route::group([
'middleware' => ['web', 'auth', 'role'],
'prefix' => config('quickadmin.route'),
'as' => config('quickadmin.route'),
'namespace' => 'App\Http\Controllers',
], function () use ($menus) {
foreach ($menus as $menu) {
Expand Down

0 comments on commit bd693a5

Please sign in to comment.