Ekapp/skolehjem/database/seeds/PermissionSeeder.php

69 lines
2.1 KiB
PHP
Raw Normal View History

2020-06-08 13:08:46 +00:00
<?php
use Illuminate\Database\Seeder;
use Spatie\Permission\Models\Permission;
class PermissionSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$permissions = [
/**
* The USER specific permissions
*/
"user.list" => "Access to list the users.",
"user.show" => "Shows another user profile.",
"user.edit" => "Allows editing of other users.",
"user.delete" => "Allows deleting of other users.",
/**
* The CALENDAR specific permissions
*/
"calendar.create" => "Create a new event.",
"calendar.list" => "Shows all events.",
"calendar.show" => "Shows a specific event.",
"calendar.edit" => "Allows editing of events.",
"calendar.delete" => "Allows the deletion of events.",
/**
* The EXTERNAL LINK specific permissions
*/
"link.external.create" => "Create a new external link.",
"link.external.list" => "List all external links.",
"link.external.show" => "Show a specific external link",
"link.external.edit" => "Allows editing of external links.",
"link.external.delete" => "Allows deletion of external links",
2020-06-30 06:49:39 +00:00
"event.create" => "Create a new event",
"event.list" => "Shows all events",
"event.show" => "Shows event",
"event.edit" => "Edit event",
"event.delete" => "Deletes an event",
2020-06-08 13:08:46 +00:00
2020-06-30 06:49:39 +00:00
"contact.create" => "Creates a new contact",
"contact.list" => ""
2020-06-08 13:08:46 +00:00
];
foreach ($permissions as $key => $value) {
2020-06-30 06:49:39 +00:00
try {
if(Permission::findByName($key))
continue;
} catch (Exception $e) {
$permission = new Permission();
2020-06-08 13:08:46 +00:00
2020-06-30 06:49:39 +00:00
$permission->name = $key;
$permission->description = $value;
2020-06-08 13:08:46 +00:00
2020-06-30 06:49:39 +00:00
$permission->save();
}
2020-06-08 13:08:46 +00:00
}
}
}