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

PermissionsSeeder::prepareSeeds()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4286
cc 2
eloc 6
nc 2
nop 1
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