1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Illuminate\Auth\UserTrait; |
4
|
|
|
use Illuminate\Auth\UserInterface; |
5
|
|
|
use Illuminate\Auth\Reminders\RemindableTrait; |
6
|
|
|
use Illuminate\Auth\Reminders\RemindableInterface; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* User |
10
|
|
|
* |
11
|
|
|
* @property-read mixed $name |
12
|
|
|
* @property integer $id |
13
|
|
|
* @property string $username |
14
|
|
|
* @property string $displayname |
15
|
|
|
* @property string $email |
16
|
|
|
* @property boolean $admin |
17
|
|
|
* @property string $remember_token |
18
|
|
|
* @property \Carbon\Carbon $created_at |
19
|
|
|
* @property \Carbon\Carbon $updated_at |
20
|
|
|
* @method static \Illuminate\Database\Query\Builder|\User whereId($value) |
21
|
|
|
* @method static \Illuminate\Database\Query\Builder|\User whereUsername($value) |
22
|
|
|
* @method static \Illuminate\Database\Query\Builder|\User whereDisplayname($value) |
23
|
|
|
* @method static \Illuminate\Database\Query\Builder|\User whereEmail($value) |
24
|
|
|
* @method static \Illuminate\Database\Query\Builder|\User whereAdmin($value) |
25
|
|
|
* @method static \Illuminate\Database\Query\Builder|\User whereRememberToken($value) |
26
|
|
|
* @method static \Illuminate\Database\Query\Builder|\User whereCreatedAt($value) |
27
|
|
|
* @method static \Illuminate\Database\Query\Builder|\User whereUpdatedAt($value) |
28
|
|
|
*/ |
29
|
|
|
class User extends Eloquent implements UserInterface, RemindableInterface { |
|
|
|
|
30
|
|
|
|
31
|
|
|
use UserTrait, RemindableTrait; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The database table used by the model. |
35
|
|
|
* |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $table = 'users'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* The attributes excluded from the model's JSON form. |
42
|
|
|
* |
43
|
|
|
* @var array |
44
|
|
|
*/ |
45
|
|
|
protected $hidden = ['password', 'remember_token']; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Get auth password |
49
|
|
|
* |
50
|
|
|
* Overwritten for mozilla persona usage. |
51
|
|
|
*/ |
52
|
|
|
public function getAuthPassword() { |
53
|
|
|
return Hash::make('moz:persona'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Get user's preferred name (username or displayname) |
58
|
|
|
*/ |
59
|
5 |
|
public function getNameAttribute() { |
60
|
5 |
|
if ($this->displayname) { |
61
|
2 |
|
return $this->displayname; |
62
|
|
|
} |
63
|
|
|
|
64
|
3 |
|
return $this->username; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.