From 041b794e1f3e0c1ba671dc74d26e3761ce108492 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 8 Jun 2017 20:24:26 -0700 Subject: [PATCH] Fixes #3634 - use new routes for groups --- app/Http/Controllers/GroupsController.php | 22 +++++----- resources/views/groups/edit.blade.php | 46 +++++++++++---------- resources/views/layouts/edit-form.blade.php | 11 +++-- routes/web.php | 14 +++---- 4 files changed, 49 insertions(+), 44 deletions(-) diff --git a/app/Http/Controllers/GroupsController.php b/app/Http/Controllers/GroupsController.php index 0514eaa81b..c5e2ebfbd7 100755 --- a/app/Http/Controllers/GroupsController.php +++ b/app/Http/Controllers/GroupsController.php @@ -28,7 +28,7 @@ class GroupsController extends Controller * @since [v1.0] * @return \Illuminate\Contracts\View\View */ - public function getIndex() + public function index() { // Show the page return View::make('groups/index', compact('groups')); @@ -42,7 +42,7 @@ class GroupsController extends Controller * @since [v1.0] * @return \Illuminate\Contracts\View\View */ - public function getCreate() + public function create() { $group = new Group; // Get all the available permissions @@ -62,7 +62,7 @@ class GroupsController extends Controller * @since [v1.0] * @return \Illuminate\Http\RedirectResponse */ - public function postCreate() + public function store() { // create a new group instance $group = new Group(); @@ -84,13 +84,13 @@ class GroupsController extends Controller * @since [v1.0] * @return \Illuminate\Contracts\View\View */ - public function getEdit($id = null) + public function edit($id = null) { $group = Group::find($id); $permissions = config('permissions'); $groupPermissions = $group->decodePermissions(); $selected_array = Helper::selectedPermissionsArray($permissions, $groupPermissions); - return View::make('groups/edit', compact('group', 'permissions', 'selected_array', 'groupPermissions')); + return View::make('groups.edit', compact('group', 'permissions', 'selected_array', 'groupPermissions')); } /** @@ -102,7 +102,7 @@ class GroupsController extends Controller * @since [v1.0] * @return \Illuminate\Http\RedirectResponse */ - public function postEdit($id = null) + public function update($id = null) { $permissions = config('permissions'); if (!$group = Group::find($id)) { @@ -113,11 +113,11 @@ class GroupsController extends Controller if (!config('app.lock_passwords')) { if ($group->save()) { - return redirect()->to("admin/groups")->with('success', trans('admin/groups/message.success.update')); + return redirect()->route('groups.index')->with('success', trans('admin/groups/message.success.update')); } return redirect()->back()->withInput()->withErrors($group->getErrors()); } - return redirect()->route('groups')->with('error', trans('general.feature_disabled')); + return redirect()->route('groups.index')->with('error', trans('general.feature_disabled')); } /** @@ -129,7 +129,7 @@ class GroupsController extends Controller * @since [v1.0] * @return \Illuminate\Http\RedirectResponse */ - public function getDelete($id = null) + public function destroy($id = null) { if (!config('app.lock_passwords')) { if (!$group = Group::find($id)) { @@ -137,9 +137,9 @@ class GroupsController extends Controller } $group->delete(); // Redirect to the group management page - return redirect()->route('groups')->with('success', trans('admin/groups/message.success.delete')); + return redirect()->route('groups.index')->with('success', trans('admin/groups/message.success.delete')); } - return redirect()->route('groups')->with('error', trans('general.feature_disabled')); + return redirect()->route('groups.index')->with('error', trans('general.feature_disabled')); } } diff --git a/resources/views/groups/edit.blade.php b/resources/views/groups/edit.blade.php index f8e63795d5..735163400f 100755 --- a/resources/views/groups/edit.blade.php +++ b/resources/views/groups/edit.blade.php @@ -1,10 +1,8 @@ @extends('layouts/edit-form', [ 'createText' => trans('admin/groups/titles.create') , 'updateText' => trans('admin/groups/titles.update'), - 'helpTitle' => trans('admin/groups/general.about_groups_title'), - 'helpText' => trans('admin/groups/general.about_groups_text'), 'item' => $group, - 'formAction' => ($group !== null && $group->id !== null) ? route('groups.update', ['accessory' => $group->id]) : route('groups.store'), + 'formAction' => ($group !== null && $group->id !== null) ? route('groups.update', ['group' => $group->id]) : route('groups.store'), ]) @section('content') @@ -28,34 +26,40 @@ -
@foreach ($permissions as $area => $permission) @for ($i = 0; $i < count($permission); $i++) + + @if ($permission[$i]['display']) -

{{ $area }}: {{ $permission[$i]['label'] }}

-

{{ $permission[$i]['note'] }}

+
+

{{ $area }}: {{ $permission[$i]['label'] }}

+

{{ $permission[$i]['note'] }}

- -
- - + +
+ + + +
+
-
+ @endif @endfor @endforeach -
+ + @stop diff --git a/resources/views/layouts/edit-form.blade.php b/resources/views/layouts/edit-form.blade.php index 818484322a..75b1427e1d 100644 --- a/resources/views/layouts/edit-form.blade.php +++ b/resources/views/layouts/edit-form.blade.php @@ -30,9 +30,11 @@ {{ $item->display_name }} @endif -
- -
+ @if (isset($helpText)) +
+ +
+ @endif
@@ -51,6 +53,8 @@
+ + @if ((isset($helpText)) && (isset($helpTitle)))
×

@@ -58,6 +62,7 @@

{{ $helpText }}

+ @endif @stop diff --git a/routes/web.php b/routes/web.php index bfaa23d036..5fd168dde3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -165,17 +165,13 @@ Route::group([ 'prefix' => 'admin','middleware' => ['auth']], function () { }); -# Group Management -Route::group([ 'prefix' => 'groups', 'middleware' => ['auth'] ], function () { - Route::get('/', [ 'as' => 'groups.index', 'uses' => 'GroupsController@getIndex' ]); - Route::get('create', [ 'as' => 'groups.create', 'uses' => 'GroupsController@getCreate']); - Route::post('create', [ 'as' => 'groups.store', 'uses' => 'GroupsController@postCreate' ]); - Route::get('{groupId}/edit', [ 'as' => 'groups.edit', 'uses' => 'GroupsController@getEdit' ]); - Route::post('{groupId}/edit', [ 'as' => 'groups.update', 'uses' => 'GroupsController@postEdit' ]); - Route::get('{groupId}/delete', [ 'as' => 'groups.delete', 'uses' => 'GroupsController@getDelete' ]); +Route::resource('groups', 'GroupsController', [ + 'middleware' => ['auth'], + 'parameters' => ['group' => 'group_id'] +]); + -}); /*