Notification hide.

This commit is contained in:
cuneytsenturk
2018-11-17 13:13:15 +03:00
parent 8b5fd52d3d
commit e78b786e42
11 changed files with 243 additions and 1 deletions

View File

@ -0,0 +1,79 @@
<?php
namespace App\Listeners\Updates;
use App\Events\UpdateFinished;
use App\Models\Auth\Role;
use App\Models\Auth\Permission;
use Artisan;
class Version132 extends Listener
{
const ALIAS = 'core';
const VERSION = '1.3.2';
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
{
// Check if should listen
if (!$this->check($event)) {
return;
}
$this->updatePermissions();
// Update database
Artisan::call('migrate', ['--force' => true]);
}
protected function updatePermissions()
{
$permissions = [];
// Banking Reconciliations
$permissions[] = Permission::firstOrCreate([
'name' => 'read-common-notifications',
'display_name' => 'Read Common Notifications',
'description' => 'Read Common Notifications',
]);
$permissions[] = Permission::firstOrCreate([
'name' => 'create-common-notifications',
'display_name' => 'Create Common Notifications',
'description' => 'Create Common Notifications',
]);
$permissions[] = Permission::firstOrCreate([
'name' => 'update-common-notifications',
'display_name' => 'Update Common Notifications',
'description' => 'Update Common Notifications',
]);
$permissions[] = Permission::firstOrCreate([
'name' => 'delete-common-notifications',
'display_name' => 'Delete Common Notifications',
'description' => 'Delete Common Notifications',
]);
// Attach permission to roles
$roles = Role::all();
foreach ($roles as $role) {
$allowed = ['admin', 'manager'];
if (!in_array($role->name, $allowed)) {
continue;
}
foreach ($permissions as $permission) {
$role->attachPermission($permission);
}
}
}
}