diff --git a/.travis.yml b/.travis.yml index a6f7a47..3b96c2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,10 @@ php: env: - APP_ENV=testing +cache: + directories: + - vendor + before_script: - travis_retry composer self-update - travis_retry composer update --prefer-source --no-interaction --dev diff --git a/app/Console/Commands/ReloadAllCommand.php b/app/Console/Commands/ReloadAllCommand.php index d8beac0..289440e 100644 --- a/app/Console/Commands/ReloadAllCommand.php +++ b/app/Console/Commands/ReloadAllCommand.php @@ -42,9 +42,7 @@ public function handle() $this->call('make:jwt'); if ($this->option('dev')) { - $this->call('db:seed', [ - '--class' => 'DevelopmentSeeder', - ]); + $this->call('seed:dev'); } } } diff --git a/app/Console/Commands/ReloadDbCommand.php b/app/Console/Commands/ReloadDbCommand.php index 55425f1..3a9b331 100644 --- a/app/Console/Commands/ReloadDbCommand.php +++ b/app/Console/Commands/ReloadDbCommand.php @@ -11,7 +11,8 @@ class ReloadDbCommand extends Command * * @var string */ - protected $signature = 'reload:db'; + protected $signature = 'reload:db + {--d|dev : Seed development data}'; /** * The console command description. @@ -38,5 +39,9 @@ public function handle() $this->call('migrate:fresh', ['--seed' => true]); $this->info('Seeding Profile Dependencies'); $this->call('profile:seed'); + + if ($this->option('dev')) { + $this->call('seed:dev'); + } } } diff --git a/app/Console/Commands/SeedDevelopmentDataCommand.php b/app/Console/Commands/SeedDevelopmentDataCommand.php new file mode 100644 index 0000000..8f659d6 --- /dev/null +++ b/app/Console/Commands/SeedDevelopmentDataCommand.php @@ -0,0 +1,42 @@ +call('db:seed', ['--class' => 'DevelopmentSeeder']); + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 2505ac7..0955153 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -17,6 +17,7 @@ class Kernel extends ConsoleKernel Commands\ReloadAllCommand::class, Commands\ReloadCacheCommand::class, Commands\ReloadDbCommand::class, + Commands\SeedDevelopmentDataCommand::class, ]; /** diff --git a/app/Http/Controllers/Api/Manage/AclController.php b/app/Http/Controllers/Api/Manage/AclController.php new file mode 100644 index 0000000..666d945 --- /dev/null +++ b/app/Http/Controllers/Api/Manage/AclController.php @@ -0,0 +1,48 @@ +type) { + case 'create': + $permissions = [ + $request->permission . '_create', + $request->permission . '_store', + ]; + break; + case 'view': + $permissions = [ + $request->permission . '_index', + $request->permission . '_show', + ]; + break; + case 'update': + $permissions = [ + $request->permission . '_edit', + $request->permission . '_update', + ]; + break; + case 'destroy': + $permissions = [ + $request->permission . '_destroy', + ]; + break; + } + + $role = role($request->role); + + foreach ($permissions as $permission) { + if($request->revoke) { + $role->revokePermissionTo($permission); + } else { + $role->givePermissionTo($permission); + } + } + } +} diff --git a/app/Http/Controllers/Manage/AclController.php b/app/Http/Controllers/Manage/AclController.php new file mode 100644 index 0000000..7e30cac --- /dev/null +++ b/app/Http/Controllers/Manage/AclController.php @@ -0,0 +1,85 @@ +parent($parent); + $breadcrumbs->push($module, route($prefix . '.index')); + }); + + // Module Name > Add + BreadcrumbsManager::register($prefix . '.create', function ($breadcrumbs) use ($prefix) { + $breadcrumbs->parent($prefix . '.index'); + $breadcrumbs->push(__('Add'), route($prefix . '.create')); + }); + + // Module Name > Details + BreadcrumbsManager::register($prefix . '.show', function ($breadcrumbs, $id) use ($prefix) { + $breadcrumbs->parent($prefix . '.index'); + $breadcrumbs->push(__('Details'), route($prefix . '.show', $id)); + }); + + // Module Name > Edit + BreadcrumbsManager::register($prefix . '.edit', function ($breadcrumbs, $id) use ($prefix) { + $breadcrumbs->parent($prefix . '.show', $id); + $breadcrumbs->push(__('Update'), route($prefix . '.edit', $id)); + }); + }); + } + } +} diff --git a/app/Providers/MacroServiceProvider.php b/app/Providers/MacroServiceProvider.php index 5f63cc1..dbf46b9 100644 --- a/app/Providers/MacroServiceProvider.php +++ b/app/Providers/MacroServiceProvider.php @@ -13,6 +13,7 @@ public function boot() { \App\Macros\Http\Response::registerMacros(); \App\Macros\Models\Model::registerMacros(); + \App\Macros\Routing\Breadcrumb::registerMacros(); } /** diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index dc912d7..a747fc3 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -30,7 +30,6 @@ public function boot() public function map() { $this->mapApiRoutes(); - $this->mapDatatableRoutes(); $this->mapWebRoutes(); } @@ -43,7 +42,12 @@ protected function mapWebRoutes() { Route::middleware('web') ->namespace($this->namespace) - ->group(base_path('routes/web.php')); + ->group(function () { + collect(glob(base_path('/routes/web/*.php'))) + ->each(function ($path) { + require $path; + }); + }); } /** @@ -57,7 +61,22 @@ protected function mapApiRoutes() ->middleware('api') ->as('api.') ->namespace($this->namespace . '\Api') - ->group(base_path('routes/api.php')); + ->group(function () { + collect(glob(base_path('/routes/api/*.php'))) + ->each(function ($path) { + require $path; + }); + + Route::prefix('datatable') + ->as('datatable.') + ->namespace('\Datatable') + ->group(function () { + collect(glob(base_path('/routes/datatable/*.php'))) + ->each(function ($path) { + require $path; + }); + }); + }); } /** @@ -67,10 +86,5 @@ protected function mapApiRoutes() */ protected function mapDatatableRoutes() { - Route::prefix('api/datatable') - ->middleware('api') - ->as('api.datatable.') - ->namespace($this->namespace . '\Api\Datatable') - ->group(base_path('routes/datatable.php')); } } diff --git a/app/Support/helpers.php b/app/Support/helpers.php index fda332c..642662c 100644 --- a/app/Support/helpers.php +++ b/app/Support/helpers.php @@ -1,5 +1,7 @@ ['developer', 'administrator'], 'passport' => ['developer'], 'user' => ['developer', 'administrator'], + 'acl' => ['developer', 'administrator'], ], 'actions' => [ 'index', 'show', diff --git a/config/breadcrumbs.php b/config/breadcrumbs.php index 726876f..df07472 100644 --- a/config/breadcrumbs.php +++ b/config/breadcrumbs.php @@ -31,7 +31,7 @@ | */ - 'files' => base_path('routes/breadcrumbs.php'), + 'files' => glob(base_path('routes/breadcrumbs/*.php')), /* |-------------------------------------------------------------------------- diff --git a/resources/views/components/forms/checkbox.blade.php b/resources/views/components/forms/checkbox.blade.php index 05aa21d..5e45ca1 100644 --- a/resources/views/components/forms/checkbox.blade.php +++ b/resources/views/components/forms/checkbox.blade.php @@ -17,6 +17,6 @@ @isset($data) @foreach($data as $key => $value) data-{{ $key }}="{{ $value }}" @endforeach @endisset - {{ isset($checked) ? 'checked' : '' }}> + {{ isset($checked) && ($checked) ? 'checked' : '' }}> {{ __($label) }} \ No newline at end of file diff --git a/resources/views/components/navigations/nav-menus.blade.php b/resources/views/components/navigations/nav-menus.blade.php index 2885dd8..06b11e1 100644 --- a/resources/views/components/navigations/nav-menus.blade.php +++ b/resources/views/components/navigations/nav-menus.blade.php @@ -21,6 +21,10 @@ @can('user_index') Users @endcan + + @can('acl_index') + ACL + @endcan