diff --git a/app/Http/Controllers/Settings/RoleController.php b/app/Http/Controllers/Settings/Access/RoleController.php similarity index 90% rename from app/Http/Controllers/Settings/RoleController.php rename to app/Http/Controllers/Settings/Access/RoleController.php index 461920b..116aa09 100644 --- a/app/Http/Controllers/Settings/RoleController.php +++ b/app/Http/Controllers/Settings/Access/RoleController.php @@ -1,5 +1,5 @@ route('role.index') + ->route('access.role.index') ->with('success', 'Role has been created successfully'); } @@ -86,7 +86,7 @@ class RoleController extends Controller //$userRoles = $user->roles->pluck('name','name')->all(); $checkeds = $role->perms->pluck('id')->toArray(); - return view('settings.role.edit', compact('role', 'permissions', 'checkeds')); + return view('settings.access.role.edit', compact('role', 'permissions', 'checkeds')); } /** @@ -114,7 +114,7 @@ class RoleController extends Controller $role->perms()->detach(); //If no role is selected remove exisiting role associated to a user } - return redirect()->route('role.index') + return redirect()->route('access.role.index') ->with('flash_message', 'Role successfully edited.'); } diff --git a/app/Http/Controllers/Settings/UserController.php b/app/Http/Controllers/Settings/Access/UserController.php similarity index 90% rename from app/Http/Controllers/Settings/UserController.php rename to app/Http/Controllers/Settings/Access/UserController.php index 20a8c35..5286599 100644 --- a/app/Http/Controllers/Settings/UserController.php +++ b/app/Http/Controllers/Settings/Access/UserController.php @@ -1,5 +1,5 @@ orderBy('id', 'DESC') ->paginate(5); - return view('settings.user.user', compact('users')) + return view('settings.access.user.user', compact('users')) ->with('i', ($request->input('page', 1) - 1) * 5); } @@ -41,7 +41,7 @@ class UserController extends Controller { //$roles = Role::pluck('name','name')->all(); $roles = Role::all('id', 'name'); - return view('settings.user.create', compact('roles')); + return view('settings.access.user.create', compact('roles')); } /** @@ -80,7 +80,7 @@ class UserController extends Controller } return redirect() - ->route('settings.user.index') + ->route('access.user.index') ->with('success', 'User has been created successfully'); } @@ -93,7 +93,7 @@ class UserController extends Controller public function show($id) { $user = User::find($id); - return view('settings.user.show', compact('user')); + return view('settings.access.user.show', compact('user')); } /** @@ -110,7 +110,7 @@ class UserController extends Controller //$userRoles = $user->roles->pluck('name','name')->all(); $checkeds = $user->roles->pluck('id')->toArray(); - return view('settings.user.edit', compact('user', 'roles', 'checkeds')); + return view('settings.access.user.edit', compact('user', 'roles', 'checkeds')); } /** @@ -150,7 +150,7 @@ class UserController extends Controller //return back()->with('flash_message', 'user successfully updated.'); return redirect() - ->route('settings.user.index') + ->route('access.user.index') ->with('flash_message', 'User successfully edited.'); } @@ -167,7 +167,7 @@ class UserController extends Controller $user->delete(); return redirect() - ->route('settings.user.index') + ->route('access.user.index') ->with('flash_message', 'User successfully deleted.'); } } diff --git a/app/Http/Controllers/Settings/PageController.php b/app/Http/Controllers/Settings/PageController.php new file mode 100644 index 0000000..73dea31 --- /dev/null +++ b/app/Http/Controllers/Settings/PageController.php @@ -0,0 +1,87 @@ +allow('view-page'); + return true; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + // + ]; + } +} diff --git a/app/Models/ModelTrait.php b/app/Models/ModelTrait.php new file mode 100644 index 0000000..92edc58 --- /dev/null +++ b/app/Models/ModelTrait.php @@ -0,0 +1,34 @@ +allow($permission)) { + return ' + + '; + } + } + + /** + * @return string + */ + public function getDeleteButtonAttribute($permission, $route) + { + if (access()->allow($permission)) { + return ' + + '; + } + } +} diff --git a/app/Models/Page.php b/app/Models/Page.php new file mode 100644 index 0000000..2a6f685 --- /dev/null +++ b/app/Models/Page.php @@ -0,0 +1,53 @@ + 1, + ]; + + protected $with = ['owner']; + + public function __construct(array $attributes = []) + { + parent::__construct($attributes); + $this->table = 'pages';//config('module.pages.table'); + } + + public function owner() + { + return $this->belongsTo(User::class, 'created_by'); + } + + /** + * @return bool + */ + public function isActive() + { + return $this->status == 1; + } +} diff --git a/composer.json b/composer.json index 103e79c..035240b 100755 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ "php": ">=7.0.0", "davejamesmiller/laravel-breadcrumbs": "4.x", "fideloper/proxy": "~3.3", + "hieu-le/active": "^3.5", "laravel/framework": "5.5.*", "laravel/tinker": "~1.0", "laravelcollective/html": "^5.5.0", diff --git a/composer.lock b/composer.lock index 12798ad..05f3c54 100755 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "00e98bda68b015c9576d1e622624cb55", + "content-hash": "12d5d5d5edbaf033404b80e81076f7fb", "packages": [ { "name": "davejamesmiller/laravel-breadcrumbs", @@ -379,6 +379,69 @@ ], "time": "2017-06-15T17:19:42+00:00" }, + { + "name": "hieu-le/active", + "version": "3.5.1", + "source": { + "type": "git", + "url": "https://github.com/letrunghieu/active.git", + "reference": "42d0f50be74b89d730bb4c0ee8c32447630506c6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/letrunghieu/active/zipball/42d0f50be74b89d730bb4c0ee8c32447630506c6", + "reference": "42d0f50be74b89d730bb4c0ee8c32447630506c6", + "shasum": "" + }, + "require": { + "laravel/framework": "^5.5", + "php": ">=7.0" + }, + "require-dev": { + "codeclimate/php-test-reporter": "dev-master", + "orchestra/testbench": "^3.1", + "phpunit/phpunit": "~6.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "HieuLe\\Active\\ActiveServiceProvider" + ], + "aliases": { + "Active": "HieuLe\\Active\\Facades\\Active" + } + } + }, + "autoload": { + "psr-4": { + "HieuLe\\Active\\": "src/", + "HieuLe\\ActiveTest\\": "tests/" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Hieu Le", + "email": "letrunghieu.cse09@gmail.com", + "homepage": "https://www.hieule.info" + } + ], + "description": "The helper class for Laravel (4/5) applications to get active class base on current route", + "homepage": "https://www.hieule.info/tag/laravel-active/", + "keywords": [ + "active", + "laravel", + "routing" + ], + "time": "2017-09-07T02:36:51+00:00" + }, { "name": "jakub-onderka/php-console-color", "version": "0.1", diff --git a/public/assets/functions.js b/public/assets/functions.js index b1b2854..255fa9e 100644 --- a/public/assets/functions.js +++ b/public/assets/functions.js @@ -32,4 +32,49 @@ toggleClass(menuLink, active); }; + var animationSpeed = 500; + $('li h2', $(menu)).on('click', function(e) { + //Get the clicked link and the next element + var $this = $(this); + var checkElement = $this.next(); + + //Check if the next element is a menu and is visible + if ((checkElement.is('.treeview-menu')) && (checkElement.is(':visible'))) { + //Close the menu + checkElement.slideUp(animationSpeed, function() { + checkElement.removeClass('menu-open'); + //Fix the layout in case the sidebar stretches over the height of the window + //_this.layout.fix(); + }); + // checkElement.parent('li').removeClass('active'); + } + //If the menu is not visible + else if ((checkElement.is('.treeview-menu')) && (!checkElement.is(':visible'))) { + //Get the parent menu + var parent = $this.parents('ul').first(); + //Close all open menus within the parent + var ul = parent.find('ul.treeview-menu:visible').slideUp(animationSpeed); + //Remove the menu-open class from the parent + ul.removeClass('menu-open'); + //Get the parent li + var liParent = $this.parent('li'); + + //Open the target menu and add the menu-open class + checkElement.slideDown(animationSpeed, function() { + //Add the class active to the parent li + checkElement.addClass('menu-open'); + // parent.find('li.active').removeClass('active'); + // liParent.addClass('active'); + //Fix the layout in case the sidebar stretches over the height of the window + // _this.layout.fix(); + }); + } + //if this isn't a link, prevent the page from being redirected + if (checkElement.is('.treeview-menu')) { + e.preventDefault(); + } + }); + + + }(this, this.document)); \ No newline at end of file diff --git a/resources/views/partials/nav.blade.php b/resources/views/partials/nav.blade.php index 8bca915..fed4797 100755 --- a/resources/views/partials/nav.blade.php +++ b/resources/views/partials/nav.blade.php @@ -83,8 +83,8 @@