updates common uploads show
This commit is contained in:
parent
373c2f89e5
commit
18e381f095
62
app/Listeners/Updates/V13/Version1311.php
Normal file
62
app/Listeners/Updates/V13/Version1311.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners\Updates\V13;
|
||||
|
||||
use App\Events\UpdateFinished;
|
||||
use App\Listeners\Updates\Listener;
|
||||
use App\Models\Auth\Role;
|
||||
use App\Models\Auth\Permission;
|
||||
use Artisan;
|
||||
|
||||
class Version1311 extends Listener
|
||||
{
|
||||
const ALIAS = 'core';
|
||||
|
||||
const VERSION = '1.3.11';
|
||||
|
||||
/**
|
||||
* 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 = [];
|
||||
|
||||
// Common Uploads
|
||||
$permissions[] = Permission::firstOrCreate([
|
||||
'name' => 'read-common-uploads',
|
||||
'display_name' => 'Read Common Uploads',
|
||||
'description' => 'Read Common Uploads',
|
||||
]);
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
'App\Listeners\Updates\V13\Version135',
|
||||
'App\Listeners\Updates\V13\Version138',
|
||||
'App\Listeners\Updates\V13\Version139',
|
||||
'App\Listeners\Updates\V13\Version1311',
|
||||
],
|
||||
'Illuminate\Auth\Events\Login' => [
|
||||
'App\Listeners\Auth\Login',
|
||||
|
Loading…
x
Reference in New Issue
Block a user