1 | <?php |
||
2 | |||
3 | namespace App\Models; |
||
4 | |||
5 | use Illuminate\Database\Eloquent\SoftDeletes; |
||
6 | use Illuminate\Foundation\Auth\User as Authenticatable; |
||
7 | use Illuminate\Notifications\Notifiable; |
||
8 | use jeremykenedy\LaravelRoles\Traits\HasRoleAndPermission; |
||
9 | |||
10 | class User extends Authenticatable |
||
11 | { |
||
12 | use HasRoleAndPermission; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
13 | use Notifiable; |
||
0 ignored issues
–
show
|
|||
14 | use SoftDeletes; |
||
15 | |||
16 | /** |
||
17 | * The database table used by the model. |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $table = 'users'; |
||
22 | |||
23 | /** |
||
24 | * The attributes that are not mass assignable. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $guarded = ['id']; |
||
29 | |||
30 | /** |
||
31 | * The attributes that are mass assignable. |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $fillable = [ |
||
36 | 'name', |
||
37 | 'email', |
||
38 | 'password', |
||
39 | ]; |
||
40 | |||
41 | /** |
||
42 | * The attributes that should be hidden for arrays. |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $hidden = [ |
||
47 | 'password', |
||
48 | 'remember_token', |
||
49 | ]; |
||
50 | |||
51 | /** |
||
52 | * Typecasted dates. |
||
53 | * |
||
54 | * @var array |
||
55 | */ |
||
56 | protected $dates = [ |
||
57 | 'created_at', |
||
58 | 'updated_at', |
||
59 | 'deleted_at', |
||
60 | ]; |
||
61 | |||
62 | /** |
||
63 | * Typecasting is awesome. |
||
64 | * |
||
65 | * @var array |
||
66 | */ |
||
67 | protected $casts = [ |
||
68 | 'name' => 'string', |
||
69 | 'email' => 'string', |
||
70 | 'password' => 'string', |
||
71 | ]; |
||
72 | |||
73 | /** |
||
74 | * Scope a query the user names. |
||
75 | * |
||
76 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
77 | * |
||
78 | * @return \Illuminate\Database\Eloquent\Builder |
||
79 | */ |
||
80 | public function scopeUserNames($query) |
||
81 | { |
||
82 | return $query->select('name') |
||
0 ignored issues
–
show
|
|||
83 | ->distinct() |
||
84 | ->orderBy('name', 'asc'); |
||
85 | } |
||
86 | } |
||
87 |