Commit d6b2f12f authored by Nicolas Widart's avatar Nicolas Widart

Adding permissions to the workshop module

parent 5159dfe0
...@@ -10,19 +10,19 @@ class SidebarViewComposer ...@@ -10,19 +10,19 @@ class SidebarViewComposer
$view->items->put('workbench', Collection::make([ $view->items->put('workbench', Collection::make([
[ [
'weight' => '1', 'weight' => '1',
'request' => Request::is("{$view->prefix}/workshop*"), 'request' => Request::is("{$view->prefix}/modules*") or Request::is("{$view->prefix}/workbench*"),
'route' => '#', 'route' => '#',
'icon-class' => 'fa fa-cogs', 'icon-class' => 'fa fa-cogs',
'title' => 'Workshop', 'title' => 'Workshop',
], ],
[ [
'request' => "{$view->prefix}/workshop/modules*", 'request' => "{$view->prefix}/modules*",
'route' => 'dashboard.modules.index', 'route' => 'dashboard.modules.index',
'icon-class' => 'fa fa-cog', 'icon-class' => 'fa fa-cog',
'title' => 'Modules', 'title' => 'Modules',
], ],
[ [
'request' => "{$view->prefix}/workshop/workbench*", 'request' => "{$view->prefix}/workbench*",
'route' => 'dashboard.workbench.index', 'route' => 'dashboard.workbench.index',
'icon-class' => 'fa fa-cog', 'icon-class' => 'fa fa-cog',
'title' => 'Workbench', 'title' => 'Workbench',
......
<?php
return [
'modules' => [
'index',
'store',
],
'workbench' => [
'index',
'generate',
'migrate',
'install',
]
];
\ No newline at end of file
...@@ -19,7 +19,9 @@ class ModulesController extends AdminBaseController ...@@ -19,7 +19,9 @@ class ModulesController extends AdminBaseController
parent::__construct(); parent::__construct();
$this->moduleManager = $moduleManager; $this->moduleManager = $moduleManager;
$this->beforeFilter('permissions');
} }
public function index() public function index()
{ {
$modules = $this->moduleManager->all(); $modules = $this->moduleManager->all();
......
...@@ -12,6 +12,12 @@ use Symfony\Component\Console\Output\BufferedOutput; ...@@ -12,6 +12,12 @@ use Symfony\Component\Console\Output\BufferedOutput;
class WorkbenchController extends AdminBaseController class WorkbenchController extends AdminBaseController
{ {
public function __construct()
{
parent::__construct();
$this->beforeFilter('permissions');
}
public function index() public function index()
{ {
return View::make('workshop::admin.workbench.index'); return View::make('workshop::admin.workbench.index');
......
<?php namespace Modules\Workshop\Http\Filters;
class PermissionFilter {
public function filter()
{
//
}
}
\ No newline at end of file
<?php <?php
Route::group(['prefix' => Config::get('core::core.admin-prefix').'/workshop', 'namespace' => 'Modules\Workshop\Http\Controllers'], Route::group(['prefix' => Config::get('core::core.admin-prefix'), 'namespace' => 'Modules\Workshop\Http\Controllers'],
function () { function () {
Route::get('modules', ['as' => 'dashboard.modules.index', 'uses' => 'ModulesController@index']); Route::get('modules', ['as' => 'dashboard.modules.index', 'uses' => 'ModulesController@index']);
Route::post('modules', ['as' => 'dashboard.modules.store', 'uses' => 'ModulesController@store']); Route::post('modules', ['as' => 'dashboard.modules.store', 'uses' => 'ModulesController@store']);
......
<?php namespace Modules\Workshop\Providers; <?php namespace Modules\Workshop\Providers;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
class WorkshopServiceProvider extends ServiceProvider class WorkshopServiceProvider extends ServiceProvider
{ {
/** /**
* Indicates if loading of the provider is deferred. * Indicates if loading of the provider is deferred.
* *
...@@ -12,6 +12,30 @@ class WorkshopServiceProvider extends ServiceProvider ...@@ -12,6 +12,30 @@ class WorkshopServiceProvider extends ServiceProvider
*/ */
protected $defer = false; protected $defer = false;
/**
* The filters base class name.
*
* @var array
*/
protected $filters = [
'permissions' => 'PermissionFilter'
];
/**
* Register the filters.
*
* @param Router $router
* @return void
*/
public function registerFilters(Router $router)
{
foreach ($this->filters as $name => $filter) {
$class = 'Modules\\Workshop\\Http\\Filters\\' . $filter;
$router->filter($name, $class);
}
}
/** /**
* Register the service provider. * Register the service provider.
* *
...@@ -19,7 +43,11 @@ class WorkshopServiceProvider extends ServiceProvider ...@@ -19,7 +43,11 @@ class WorkshopServiceProvider extends ServiceProvider
*/ */
public function register() public function register()
{ {
// $this->app->booted(
function ($app) {
$this->registerFilters($app['router']);
}
);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment