Completed
Push — master ( e43e24...a5d827 )
by ARCANEDEV
05:31
created

PermissionsSeeder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A seed() 0 6 1
A prepareSeeds() 0 11 2
1
<?php namespace Arcanesoft\Auth\Seeds;
2
3
use Arcanesoft\Auth\Bases\Seeder;
4
use Arcanesoft\Auth\Models\Permission;
5
use Carbon\Carbon;
6
7
/**
8
 * Class     PermissionsSeeder
9
 *
10
 * @package  Arcanesoft\Auth\Seeds
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
abstract class PermissionsSeeder extends Seeder
14
{
15
    /* ------------------------------------------------------------------------------------------------
16
     |  Main Functions
17
     | ------------------------------------------------------------------------------------------------
18
     */
19
    /**
20
     * Seed permissions.
21
     *
22
     * @param  array  $permissions
23
     */
24
    public function seed(array $permissions)
25
    {
26
        $seeds = $this->prepareSeeds($permissions);
27
28
        Permission::insert($seeds);
0 ignored issues
show
Bug introduced by
The method insert() does not exist on Arcanesoft\Auth\Models\Permission. Did you maybe mean insertAndSetId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
29
    }
30
31
    /* ------------------------------------------------------------------------------------------------
32
     |  Other Functions
33
     | ------------------------------------------------------------------------------------------------
34
     */
35
    /**
36
     * @param array $seeds
37
     *
38
     * @return array
39
     */
40
    protected function prepareSeeds(array $seeds)
41
    {
42
        $now   = Carbon::now();
43
44
        foreach ($seeds as $key => $permission) {
45
            $seeds[$key]['created_at'] = $now;
46
            $seeds[$key]['updated_at'] = $now;
47
        }
48
49
        return $seeds;
50
    }
51
}
52