GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 7079db...84589d )
by Alireza
01:29
created

AdminSeeder::run()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 36

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 8.7217
c 0
b 0
f 0
cc 6
nc 6
nop 0
1
<?php
2
3
namespace Serverfireteam\Panel\Database\Seeders;
4
5
/*
6
 * To change this license header, choose License Headers in Project Properties.
7
 * To change this template file, choose Tools | Templates
8
 * and open the template in the editor.
9
 */
10
11
use Illuminate\Database\Seeder;
12
use Spatie\Permission\Models\Role;
13
use Spatie\Permission\Models\Permission;
14
use Serverfireteam\Panel\Admin;
15
16
class AdminSeeder extends Seeder
17
{
18
    public function run()
19
    {
20
        $role = Role::firstOrCreate(
0 ignored issues
show
Bug introduced by
The method firstOrCreate() does not exist on Spatie\Permission\Models\Role. Did you maybe mean create()?

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...
21
            [
22
                'name' => config('panel.adminRole', 'admin'),
23
                'guard_name' => 'web'
24
            ]
25
        );
26
27
        $permission = Permission::firstOrCreate(
0 ignored issues
show
Bug introduced by
The method firstOrCreate() does not exist on Spatie\Permission\Models\Permission. Did you maybe mean create()?

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...
28
            [
29
                'name' => 'access panel',
30
                'guard_name' => 'web'
31
            ]
32
        );
33
34
        if (! $role->hasPermissionTo('access panel')) {
35
            $role->givePermissionTo($permission);
36
        }
37
38
        if ($this->command->confirm('Create or update a super-admin now?', true)) {
39
            $adminEmail = $this->command->ask('Email: ', '[email protected]');
40
            $admin = Admin::firstOrNew(
41
                [
42
                    'email' => $adminEmail,
43
                ]
44
            );
45
            $admin->name = $this->command->ask('Name: ', $admin->name ?: 'Administrator');
46
            if (! $admin->password) {
47
                $admin->password = bcrypt(
48
                    $this->command->secret(' Password: ', $admin->name ?: '12345')
0 ignored issues
show
Documentation introduced by
$admin->name ?: '12345' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
49
                );
50
            }
51
            $admin->save();
52
        }
53
    }
54
}
55