Skip to content

Instantly share code, notes, and snippets.

@programarivm
Last active December 26, 2019 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save programarivm/1a07ac02268cd3b25708acb788805e66 to your computer and use it in GitHub Desktop.
Save programarivm/1a07ac02268cd3b25708acb788805e66 to your computer and use it in GitHub Desktop.
Artisan command to easily set up the ACL
<?php
namespace App\Console\Commands;
use App\Acl;
use Illuminate\Console\Command;
class AclSetup extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'acl:setup';
/**
* The console command description.
*
* @var string
*/
protected $description = 'ACL setup.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
foreach (Acl::CHOICE_PERMISSIONS as $role => $resources) {
foreach ($resources as $resource) {
$restaurant = Acl::create([
'resource' => $resource,
'role' => $role,
]);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment