Completed
Push — master ( 173874...712b6b )
by Andrey
08:18
created

PermissionSeeder::createRecord()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
namespace Database\Seeders;
3
4
use Illuminate\Database\Seeder;
5
use Itstructure\LaRbac\Models\Permission;
6
7
/**
8
 * Class PermissionSeeder
9
 *
10
 * @author Andrey Girnik <[email protected]>
11
 */
12
class PermissionSeeder extends Seeder
13
{
14
    /**
15
     * Run the database seeds.
16
     * @return void
17
     */
18
    public function run()
19
    {
20
        $this->createRecord(
21
            Permission::ADMINISTRATE_PERMISSION,
22
            'Total administrate of users and content'
23
        );
24
25
        $this->createRecord(
26
            Permission::VIEW_RECORD_PERMISSION,
27
            'Permission to view record'
28
        );
29
30
        $this->createRecord(
31
            Permission::CREATE_RECORD_PERMISSION,
32
            'Permission to create record'
33
        );
34
35
        $this->createRecord(
36
            Permission::UPDATE_RECORD_PERMISSION,
37
            'Permission to update record'
38
        );
39
40
        $this->createRecord(
41
            Permission::DELETE_RECORD_PERMISSION,
42
            'Permission to delete record'
43
        );
44
45
        $this->createRecord(
46
            Permission::PUBLISH_RECORD_PERMISSION,
47
            'Permission to publish record'
48
        );
49
    }
50
51
    /**
52
     * Create permission record in database.
53
     * @param string $slug
54
     * @param string $description
55
     * @return void
56
     */
57
    private function createRecord(string $slug, string $description): void
58
    {
59
        Permission::create([
60
            'name' => str_replace('-', ' ', ucfirst($slug)),
61
            'slug' => $slug,
62
            'description' => $description,
63
        ]);
64
    }
65
}
66