Skip to content

Commit

Permalink
Remove hardcoded "watchthower" from all route names. Config option to…
Browse files Browse the repository at this point in the history
… specify whatever is desired.
  • Loading branch information
landjea committed Jan 25, 2016
1 parent e838f90 commit f369b30
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 85 deletions.
10 changes: 8 additions & 2 deletions src/Config/watchtower.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@

/*
|--------------------------------------------------------------------------
| Route Prefix
| Route Options
|--------------------------------------------------------------------------
|
| If you want to prefix all your watchtower routes, enter the prefix here.
Expand All @@ -211,8 +211,14 @@
| like 'http://<yoursite>/admin/watchtower/user' instead of
| 'http://<yoursite>/watchtower/user'. Default is none.
|
| If you want to use something other than "watchtower" in your named routes
| you can specify it here.
|
*/
'route_prefix' => '',
'route' => [
'prefix' => '',
'as' => 'watchtower.'
],

/*
|--------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions src/Controllers/PermissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function store(StoreRequest $request)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! Permission created.";
}

return redirect()->route('watchtower.permission.index')
return redirect()->route( config('watchtower.route.as') .'permission.index')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand Down Expand Up @@ -158,7 +158,7 @@ public function update($id, UpdateRequest $request)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! Permission edited.";
}

return redirect()->route('watchtower.permission.index')
return redirect()->route( config('watchtower.route.as') .'permission.index')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand All @@ -179,7 +179,7 @@ public function destroy($id)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! Permission deleted.";
}

return redirect()->route('watchtower.permission.index')
return redirect()->route( config('watchtower.route.as') .'permission.index')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand Down Expand Up @@ -228,7 +228,7 @@ public function updateRole($id, Request $request)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! Permission roles edited.";
}

return redirect()->route('watchtower.permission.index')
return redirect()->route( config('watchtower.route.as') .'permission.index')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand Down
12 changes: 6 additions & 6 deletions src/Controllers/RoleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function store(StoreRequest $request)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! Role created.";
}

return redirect()->route('watchtower.role.index')
return redirect()->route( config('watchtower.route.as') .'role.index')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand Down Expand Up @@ -159,7 +159,7 @@ public function update($id, UpdateRequest $request)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! Role edited.";
}

return redirect()->route('watchtower.role.index')
return redirect()->route( config('watchtower.route.as') .'role.index')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand All @@ -180,7 +180,7 @@ public function destroy($id)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! Role deleted.";
}

return redirect()->route('watchtower.role.index')
return redirect()->route( config('watchtower.route.as') .'role.index')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand Down Expand Up @@ -229,7 +229,7 @@ public function updateRolePermissions($id, Request $request)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! Role permissions updated.";
}

return redirect()->route('watchtower.role.index')
return redirect()->route( config('watchtower.route.as') .'role.index')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand Down Expand Up @@ -278,7 +278,7 @@ public function updateRoleUsers($id, Request $request)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! Role users updated.";
}

return redirect()->route('watchtower.role.index')
return redirect()->route( config('watchtower.route.as') .'role.index')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand Down Expand Up @@ -330,7 +330,7 @@ public function updateRoleMatrix(Request $request)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! Role permissions updated.";
}

return redirect()->route('watchtower.role.matrix')
return redirect()->route( config('watchtower.route.as') .'role.matrix')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand Down
10 changes: 5 additions & 5 deletions src/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function store(UserStoreRequest $request)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! User created.";
}

return redirect()->route('watchtower.user.index')
return redirect()->route( config('watchtower.route.as') . 'user.index')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand Down Expand Up @@ -139,7 +139,7 @@ public function update($id, UserUpdateRequest $request)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! User edited.";
}

return redirect()->route('watchtower.user.index')
return redirect()->route( config('watchtower.route.as') . 'user.index')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand All @@ -160,7 +160,7 @@ public function destroy($id)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! User deleted.";
}

return redirect()->route('watchtower.user.index')
return redirect()->route( config('watchtower.route.as') . 'user.index')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand Down Expand Up @@ -209,7 +209,7 @@ public function updateUserRoles($id, Request $request)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! User roles edited.";
}

return redirect()->route('watchtower.user.index')
return redirect()->route( config('watchtower.route.as') . 'user.index')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand Down Expand Up @@ -260,7 +260,7 @@ public function updateUserMatrix(Request $request)
$message = "<i class='fa fa-check-square-o fa-1x'></i> Success! User roles updated.";
}

return redirect()->route('watchtower.user.matrix')
return redirect()->route( config('watchtower.route.as') . 'user.matrix')
->with( ['flash' => ['message' => $message, 'level' => $level] ] );
}

Expand Down
24 changes: 12 additions & 12 deletions src/Views/layouts/master.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{ route('watchtower.index') }}">{{ $title }}</a>
<a class="navbar-brand" href="{{ route( config('watchtower.route.as').'index') }}">{{ $title }}</a>
</div>

<div id="navbar-collapse" class="navbar-collapse collapse">
Expand All @@ -71,29 +71,29 @@
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" title="Users">
<i class="fa fa-user fa-lg"></i><span class="sr-only"> Users</span> <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{{ route('watchtower.user.create') }}"><i class="fa fa-fw fa-plus"></i> Add user</a></li>
<li><a href="{{ route('watchtower.user.index') }}"><i class="fa fa-fw fa-th-list"></i> List users</a></li>
<li><a href="{{ route('watchtower.user.matrix') }}"><i class="fa fa-fw fa-table"></i> User Matrix</a></li>
<li><a href="{{ route( config('watchtower.route.as') . 'user.create') }}"><i class="fa fa-fw fa-plus"></i> Add user</a></li>
<li><a href="{{ route( config('watchtower.route.as') . 'user.index') }}"><i class="fa fa-fw fa-th-list"></i> List users</a></li>
<li><a href="{{ route( config('watchtower.route.as') . 'user.matrix') }}"><i class="fa fa-fw fa-table"></i> User Matrix</a></li>
</ul>
</li>

<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" title="Roles">
<i class="fa fa-users fa-lg"></i><span class="sr-only"> Roles</span> <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{{ route('watchtower.role.create') }}"><i class="fa fa-fw fa-plus"></i> Add role</a></li>
<li><a href="{{ route('watchtower.role.index') }}"><i class="fa fa-fw fa-th-list"></i> List roles</a></li>
<li><a href="{{ route('watchtower.role.matrix') }}"><i class="fa fa-fw fa-table"></i> Role Matrix</a></li>
<li><a href="{{ route( config('watchtower.route.as') .'role.create') }}"><i class="fa fa-fw fa-plus"></i> Add role</a></li>
<li><a href="{{ route( config('watchtower.route.as') .'role.index') }}"><i class="fa fa-fw fa-th-list"></i> List roles</a></li>
<li><a href="{{ route( config('watchtower.route.as') .'role.matrix') }}"><i class="fa fa-fw fa-table"></i> Role Matrix</a></li>
</ul>
</li>

<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" title="Permissions">
<i class="fa fa-key fa-lg"></i><span class="sr-only"> Permissions</span> <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{{ route('watchtower.permission.create') }}"><i class="fa fa-fw fa-plus"></i> Add permission</a></li>
<li><a href="{{ route('watchtower.permission.index') }}"><i class="fa fa-fw fa-th-list"></i> List permissions</a></li>
<li><a href="{{ route('watchtower.role.matrix') }}"><i class="fa fa-fw fa-table"></i> Role Matrix</a></li>
<li><a href="{{ route( config('watchtower.route.as') .'permission.create') }}"><i class="fa fa-fw fa-plus"></i> Add permission</a></li>
<li><a href="{{ route( config('watchtower.route.as') .'permission.index') }}"><i class="fa fa-fw fa-th-list"></i> List permissions</a></li>
<li><a href="{{ route( config('watchtower.route.as') .'role.matrix') }}"><i class="fa fa-fw fa-table"></i> Role Matrix</a></li>
</ul>
</li>

Expand All @@ -102,12 +102,12 @@
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" title="User Information">
<i class="glyphicon glyphicon-user"></i> {{ Auth::user()->name }} <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{{ route('watchtower.index') }}"><i class="fa fa-fw fa-tasks"></i> Dashboard</a></li>
<li><a href="{{ route( config('watchtower.route.as') . 'index') }}"><i class="fa fa-fw fa-tasks"></i> Dashboard</a></li>

<li role="separator" class="divider"></li>
<li class="text-muted text-center"><i class="fa fa-users"></i> Your Roles</li>
@forelse(Auth::user()->roles as $role)
<li><a href="{{ route('watchtower.role.permission.edit', $role->id) }}"><i class="fa fa-users fa-xs"></i> {{ $role->name }}</a></li>
<li><a href="{{ route( config('watchtower.route.as') . 'role.permission.edit', $role->id) }}"><i class="fa fa-users fa-xs"></i> {{ $role->name }}</a></li>
@empty
<li><a href="#"><i class="fa fa-hand-stop-o fa-xs"></i> No roles</a></li>
@endforelse
Expand Down
2 changes: 1 addition & 1 deletion src/Views/partials/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h1>Create New {{ $route }}</h1>
<hr/>

{!! Form::open( ['route' => 'watchtower.'.$route.'.store', 'class' => 'form-horizontal']) !!}
{!! Form::open( ['route' => config('watchtower.route.as') . $route .'.store', 'class' => 'form-horizontal']) !!}

<div class="form-group {{ $errors->has('name') ? 'has-error' : ''}}">
{!! Form::label('name', 'Name: ', ['class' => 'col-sm-3 control-label']) !!}
Expand Down
2 changes: 1 addition & 1 deletion src/Views/partials/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h1>{{ ( ($show == '0') ? 'Edit' : 'Viewing' ) }} '{{ $resource->name }}'</h1>
<hr/>

{!! Form::model($resource, ['method' => 'PATCH', 'route' => [ 'watchtower.'.$route.'.update', $resource->id ], 'class' => 'form-horizontal']) !!}
{!! Form::model($resource, ['method' => 'PATCH', 'route' => [ config('watchtower.route.as') . $route .'.update', $resource->id ], 'class' => 'form-horizontal']) !!}
{!! Form::hidden('id', $resource->id) !!}

<div class="form-group {{ $errors->has('name') ? 'has-error' : ''}}">
Expand Down
12 changes: 6 additions & 6 deletions src/Views/permission/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@endif

@if ( Shinobi::can( config('watchtower.acl.permission.create', false) ) )
<a href="{{ route('watchtower.permission.create') }}">
<a href="{{ route( config('watchtower.route.as') .'permission.create') }}">
<button type="button" class="btn btn-info">
<i class="fa fa-plus fa-fw"></i>
<span class="hidden-xs hidden-sm">Add New Permission</span>
Expand All @@ -23,7 +23,7 @@
</h1>

<!-- search bar -->
@include( config('watchtower.views.layouts.search'), [ 'search_route' => 'watchtower.permission.index', 'items' => $permissions, 'acl' => 'permission' ] )
@include( config('watchtower.views.layouts.search'), [ 'search_route' => config('watchtower.route.as') .'permission.index', 'items' => $permissions, 'acl' => 'permission' ] )

<div class="table">
<table class="table table-hover">
Expand All @@ -39,28 +39,28 @@
<td>{{ $item->id }}</td>

<td>
<a href="{{ route('watchtower.permission.show', $item->id) }}">{{ $item->name }}</a>
<a href="{{ route( config('watchtower.route.as') .'permission.show', $item->id) }}">{{ $item->name }}</a>
</td>

<td>
@if ( Shinobi::can( config('watchtower.acl.permission.role', false)) )
<a href="{{ route('watchtower.permission.role.edit', $item->id) }}">
<a href="{{ route( config('watchtower.route.as') .'permission.role.edit', $item->id) }}">
<button type="button" class="btn btn-primary btn-xs">
<i class="fa fa-users fa-fw"></i>
<span class="hidden-xs hidden-sm">Roles</span>
</button></a>
@endif

@if ( Shinobi::can( config('watchtower.acl.permission.edit', false)) )
<a href="{{ route('watchtower.permission.edit', $item->id) }}">
<a href="{{ route( config('watchtower.route.as') .'permission.edit', $item->id) }}">
<button type="button" class="btn btn-default btn-xs">
<i class="fa fa-pencil fa-fw"></i>
<span class="hidden-xs hidden-sm">Update</span>
</button></a>
@endif

@if ( Shinobi::can( config('watchtower.acl.permission.destroy', false) ) )
{!! Form::open(['method'=>'delete','route'=> ['watchtower.permission.destroy',$item->id], 'style' => 'display:inline']) !!}
{!! Form::open(['method'=>'delete','route'=> [ config('watchtower.route.as') .'permission.destroy',$item->id], 'style' => 'display:inline']) !!}
<button type="submit" class="btn btn-danger btn-xs">
<i class="fa fa-trash-o fa-lg"></i>
<span class="hidden-xs hidden-sm">Delete</span>
Expand Down
2 changes: 1 addition & 1 deletion src/Views/permission/role.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h1>'{{ $permission->name }}' Roles</h1>
<hr/>

{!! Form::model($permission, [ 'route' => [ 'watchtower.permission.role.update', $permission->id ], 'class' => 'form-horizontal']) !!}
{!! Form::model($permission, [ 'route' => [ config('watchtower.route.as') .'permission.role.update', $permission->id ], 'class' => 'form-horizontal']) !!}
{!! Form::hidden('id', $permission->id) !!}

<div class="row">
Expand Down
16 changes: 8 additions & 8 deletions src/Views/role/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<h1>Roles
<div class="btn-group pull-right" role="group" aria-label="...">
@if ( Shinobi::can( config('watchtower.acl.role.viewmatrix', false) ) )
<a href="{{ route('watchtower.role.matrix') }}">
<a href="{{ route( config('watchtower.route.as') .'role.matrix') }}">
<button type="button" class="btn btn-default">
<i class="fa fa-th fa-fw"></i>
<span class="hidden-xs hidden-sm">Role Matrix</span>
</button></a>
@endif

@if ( Shinobi::can( config('watchtower.acl.role.create', false) ) )
<a href="{{ route('watchtower.role.create') }}">
<a href="{{ route( config('watchtower.route.as') .'role.create') }}">
<button type="button" class="btn btn-info">
<i class="fa fa-plus fa-fw"></i>
<span class="hidden-xs hidden-sm">Add New Role</span>
Expand All @@ -23,7 +23,7 @@
</h1>

<!-- search bar -->
@include( config('watchtower.views.layouts.search'), [ 'search_route' => 'watchtower.role.index', 'items' => $roles, 'acl' => 'role' ] )
@include( config('watchtower.views.layouts.search'), [ 'search_route' => config('watchtower.route.as') .'role.index', 'items' => $roles, 'acl' => 'role' ] )

<div class="table">
<table class="table table-hover">
Expand All @@ -39,7 +39,7 @@
<td>{{ $item->id }}</td>

<td>
<a href="{{ route('watchtower.role.show', $item->id) }}">{{ $item->name }}</a>
<a href="{{ route( config('watchtower.route.as') .'role.show', $item->id) }}">{{ $item->name }}</a>
@if ($item->special == 'all-access')
<i class="fa fa-star text-success"></i>
@elseif ($item->special == 'no-access')
Expand All @@ -49,31 +49,31 @@

<td>
@if ( Shinobi::can( config('watchtower.acl.role.permission', false)) )
<a href="{{ route('watchtower.role.permission.edit', $item->id) }}">
<a href="{{ route( config('watchtower.route.as') .'role.permission.edit', $item->id) }}">
<button type="button" class="btn btn-primary btn-xs">
<i class="fa fa-key fa-fw"></i>
<span class="hidden-xs hidden-sm">Permissions</span>
</button></a>
@endif

@if ( Shinobi::can( config('watchtower.acl.role.user', false)) )
<a href="{{ route('watchtower.role.user.edit', $item->id) }}">
<a href="{{ route( config('watchtower.route.as') .'role.user.edit', $item->id) }}">
<button type="button" class="btn btn-primary btn-xs">
<i class="fa fa-user fa-fw"></i>
<span class="hidden-xs hidden-sm">Users</span>
</button></a>
@endif

@if ( Shinobi::can( config('watchtower.acl.role.edit', false)) )
<a href="{{ route('watchtower.role.edit', $item->id) }}">
<a href="{{ route( config('watchtower.route.as') .'role.edit', $item->id) }}">
<button type="button" class="btn btn-default btn-xs">
<i class="fa fa-pencil fa-fw"></i>
<span class="hidden-xs hidden-sm">Update</span>
</button></a>
@endif

@if ( Shinobi::can( config('watchtower.acl.role.destroy', false)) )
{!! Form::open(['method'=>'delete','route'=> ['watchtower.role.destroy',$item->id], 'style' => 'display:inline']) !!}
{!! Form::open(['method'=>'delete','route'=> [ config('watchtower.route.as') .'role.destroy',$item->id], 'style' => 'display:inline']) !!}
<button type="submit" class="btn btn-danger btn-xs">
<i class="fa fa-trash-o fa-lg"></i>
<span class="hidden-xs hidden-sm">Delete</span>
Expand Down
Loading

0 comments on commit f369b30

Please sign in to comment.