Passed
Push — master ( 6955bf...21f25e )
by Eric
03:13
created

first_user_as_task_manager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Spatie\Permission\Models\Permission;
4
use Spatie\Permission\Models\Role;
5
6
if (! function_exists('initialize_task_permission')){
7
    function initialize_task_permissions() {
8
        Permission::firstOrCreate(['name' => 'list-tasks']);
9
        Permission::firstOrCreate(['name' => 'show-tasks']);
10
        Permission::firstOrCreate(['name' => 'store-tasks']);
11
        Permission::firstOrCreate(['name' => 'update-tasks']);
12
        Permission::firstOrCreate(['name' => 'destroy-tasks']);
13
14
        $role = Role::firstOrCreate(['name' => 'task-manager']);
15
16
        $role->givePermissionTo('list-tasks');
17
        $role->givePermissionTo('show-tasks');
18
        $role->givePermissionTo('store-tasks');
19
        $role->givePermissionTo('update-tasks');
20
        $role->givePermissionTo('destroy-tasks');
21
    }
22
}
23
24
if (! function_exists('create_user')){
25
    function create_user() {
26
        factory(User::class)->create([
0 ignored issues
show
Bug introduced by
The type User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
            'name' => env('TASKS_USER_NAME','Eric Garcia Reverter'),
28
            'email' => env('TASKS_USER_EMAIL','[email protected]'),
29
            'password' => bcrypt(env('TASKS_USER_PASSWORD'))
30
        ]);
31
    }
32
}
33
34
if (! function_exists('first_user_as_task_manager')){
35
    function first_user_as_task_manager() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
36
        User::all()->first()->assignRole('task-manager');
37
    }
38
}