SentinelUserSeedTableSeeder   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 31
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 23 1
1
<?php namespace Modules\User\Database\Seeders;
2
3
use Cartalyst\Sentinel\Laravel\Facades\Activation;
4
use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Seeder;
7
8
class SentinelUserSeedTableSeeder extends Seeder
9
{
10
    /**
11
     * Run the database seeds.
12
     *
13
     * @return void
14
     */
15
    public function run()
16
    {
17
        Model::unguard();
18
19
        // Create an admin user
20
        $user = Sentinel::create(
21
            [
22
                'email' => '[email protected]',
23
                'password' => 'test',
24
                'first_name' => 'Nicolas',
25
                'last_name' => 'Widart',
26
            ]
27
        );
28
        // Activate the admin directly
29
        $activation = Activation::create($user);
30
        Activation::complete($user, $activation->code);
31
32
        // Find the group using the group id
33
        $adminGroup = Sentinel::findRoleBySlug('admin');
34
35
        // Assign the group to the user
36
        $adminGroup->users()->attach($user);
37
    }
38
}
39