Completed
Push — master ( f9e78a...edb43e )
by Abdelrahman
09:22
created

UsersSeeder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 26 2
1
<?php
2
3
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Fort Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Fort Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
namespace Rinvex\Fort\Seeds;
17
18
use Carbon\Carbon;
19
use Rinvex\Fort\Models\User;
20
use Illuminate\Database\Seeder;
21
use Illuminate\Support\Facades\DB;
22
23
class UsersSeeder extends Seeder
24
{
25
    /**
26
     * Run the database seeds.
27
     *
28
     * @return void
29
     */
30
    public function run()
31
    {
32
        DB::statement('SET FOREIGN_KEY_CHECKS=0;');
33
        DB::table(config('rinvex.fort.tables.users'))->truncate();
34
35
        $user = [
36
            'username' => 'Fort',
37
            'email' => '[email protected]',
38
            'email_verified' => true,
39
            'email_verified_at' => Carbon::now(),
40
            'remember_token' => str_random(10),
41
            'password' => $password = str_random(),
42
            'active' => true,
43
        ];
44
45
        $user = User::create($user);
46
47
        if (isset($this->command)) {
48
            $this->command->getOutput()->writeln("<comment>Username</comment>: {$user['username']} / <comment>Password</comment>: {$password}");
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 144 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
49
        }
50
51
        // Assign roles to users
52
        $user->assignRoles('admin');
53
54
        DB::statement('SET FOREIGN_KEY_CHECKS=1;');
55
    }
56
}
57