1 | <?php |
||
40 | class User extends Model implements AuthenticatableContract, CanResetPasswordContract |
||
41 | { |
||
42 | use Authenticatable, CanResetPassword, ValidatingTrait, EntrustUserTrait; |
||
43 | |||
44 | /** |
||
45 | * The attributes that should be casted to native types. |
||
46 | * |
||
47 | * @var string[] |
||
48 | */ |
||
49 | protected $casts = [ |
||
50 | 'id' => 'int', |
||
51 | 'username' => 'string', |
||
52 | 'email' => 'string', |
||
53 | 'api_key' => 'string', |
||
54 | 'active' => 'bool', |
||
55 | 'level' => 'int', |
||
56 | ]; |
||
57 | |||
58 | /** |
||
59 | * The properties that cannot be mass assigned. |
||
60 | * |
||
61 | * @var string[] |
||
62 | */ |
||
63 | protected $guarded = []; |
||
64 | |||
65 | /** |
||
66 | * The hidden properties. |
||
67 | * |
||
68 | * These are excluded when we are serializing the model. |
||
69 | * |
||
70 | * @var string[] |
||
71 | */ |
||
72 | protected $hidden = ['password', 'remember_token']; |
||
73 | |||
74 | /** |
||
75 | * The validation rules. |
||
76 | * |
||
77 | * @var string[] |
||
78 | */ |
||
79 | public $rules = [ |
||
80 | 'username' => ['required', 'regex:/\A(?!.*[:;]-\))[ -~]+\z/'], |
||
81 | 'email' => 'required|email', |
||
82 | 'password' => 'required', |
||
83 | ]; |
||
84 | |||
85 | /** |
||
86 | * Overrides the models boot method. |
||
87 | */ |
||
88 | public static function boot() |
||
98 | |||
99 | /** |
||
100 | * Hash any password being inserted by default. |
||
101 | * |
||
102 | * @param string $password |
||
103 | * |
||
104 | * @return \Gitamin\Models\User |
||
105 | */ |
||
106 | public function setPasswordAttribute($password) |
||
112 | |||
113 | /** |
||
114 | * Returns a Gravatar URL for the users email address. |
||
115 | * |
||
116 | * @param int $size |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | public function getGravatarAttribute($size = 200) |
||
125 | |||
126 | /** |
||
127 | * Find by api_key, or throw an exception. |
||
128 | * |
||
129 | * @param string $token |
||
130 | * @param string[] $columns |
||
131 | * |
||
132 | * @throws \Illuminate\Database\Eloquent\ModelNotFoundException |
||
133 | * |
||
134 | * @return \Gitamin\Models\User |
||
135 | */ |
||
136 | public static function findByApiToken($token, $columns = ['*']) |
||
146 | |||
147 | /** |
||
148 | * Returns an API key. |
||
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | public static function generateApiKey() |
||
156 | |||
157 | /** |
||
158 | * Returns whether a user is approved. |
||
159 | * |
||
160 | * @return bool |
||
161 | */ |
||
162 | public function isApproved() |
||
166 | |||
167 | /** |
||
168 | * Returns whether a user is at admin level. |
||
169 | * |
||
170 | * @return bool |
||
171 | */ |
||
172 | public function getIsAdminAttribute() |
||
176 | |||
177 | /** |
||
178 | * A user can have many issues. |
||
179 | * |
||
180 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
181 | */ |
||
182 | public function issues() |
||
186 | } |
||
187 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.