Passed
Push — develop ( 1da0fd...e5012b )
by Nikita
07:14
created

User   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setPasswordAttribute() 0 3 1
A servers() 0 3 1
1
<?php
2
3
namespace Gameap\Models;
4
5
use Illuminate\Notifications\Notifiable;
6
use Illuminate\Foundation\Auth\User as Authenticatable;
7
use Spatie\Permission\Traits\HasRoles;
8
use Sofa\Eloquence\Validable;
9
use Sofa\Eloquence\Contracts\Validable as ValidableContract;
10
11
class User extends Authenticatable implements ValidableContract
12
{
13
    use Notifiable;
0 ignored issues
show
introduced by
The trait Illuminate\Notifications\Notifiable requires some properties which are not provided by Gameap\Models\User: $email, $phone_number
Loading history...
14
    use HasRoles;
0 ignored issues
show
introduced by
The trait Spatie\Permission\Traits\HasRoles requires some properties which are not provided by Gameap\Models\User: $name, $map, $permissions, $roles, $guard_name
Loading history...
15
    use Validable;
16
17
    /**
18
     * The attributes that are mass assignable.
19
     *
20
     * @var array
21
     */
22
    protected $fillable = [
23
        'login', 'email', 'password', 'name'
24
    ];
25
26
    /**
27
     * The attributes that should be hidden for arrays.
28
     *
29
     * @var array
30
     */
31
    protected $hidden = [
32
        'password', 'remember_token',
33
    ];
34
35
    /**
36
     * Validation rules
37
     * 
38
     * @var array
39
     */
40
    protected static $rules = [
41
        'login'     => 'sometimes|string|max:255|unique:users',
42
        'email'     => 'sometimes|string|email|max:255|unique:users',
43
        'password'  => 'sometimes|string|min:6|confirmed',
44
        'name'      => 'string|nullable|max:255',
45
    ];
46
47
    /**
48
     * Hash password
49
     *
50
     * @param $value
51
     */
52
    public function setPasswordAttribute($value)
53
    {
54
        $this->attributes['password'] = bcrypt($value);
55
    }
56
57
    public function servers()
58
    {
59
        return $this->belongsToMany(Server::class);
60
    }
61
}
62