-
Notifications
You must be signed in to change notification settings - Fork 14
/
FinishInstallation.php
54 lines (44 loc) · 1.19 KB
/
FinishInstallation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Modules\MyBlog\Listeners;
use App\Events\Module\Installed as Event;
use App\Traits\Permissions;
use Illuminate\Support\Facades\Artisan;
class FinishInstallation
{
use Permissions;
public $alias = 'my-blog';
/**
* Handle the event.
*
* @param Event $event
* @return void
*/
public function handle(Event $event)
{
if ($event->alias != $this->alias) {
return;
}
$this->updatePermissions();
$this->callSeeds();
}
protected function updatePermissions()
{
// c=create, r=read, u=update, d=delete
$this->attachPermissionsToAdminRoles([
$this->alias . '-posts' => 'c,r,u,d',
$this->alias . '-comments' => 'c,r,u,d',
]);
// c=create, r=read, u=update, d=delete
$this->attachPermissionsToPortalRoles([
$this->alias . '-portal-posts' => 'r',
$this->alias . '-portal-comments' => 'c,r',
]);
}
protected function callSeeds()
{
Artisan::call('company:seed', [
'company' => company_id(),
'--class' => 'Modules\MyBlog\Database\Seeds\Install',
]);
}
}