Last active
December 26, 2019 19:55
-
-
Save programarivm/1a07ac02268cd3b25708acb788805e66 to your computer and use it in GitHub Desktop.
Artisan command to easily set up the ACL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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