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

User::servers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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