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