| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Models; |
| 4 |
|
| 5 |
class User extends Model |
| 6 |
{ |
| 7 |
/** |
| 8 |
* The table associated with the model. |
| 9 |
* |
| 10 |
* @var string |
| 11 |
*/ |
| 12 |
protected $table = 'users'; |
| 13 |
|
| 14 |
/** |
| 15 |
* The accessors to append to the model's array form. |
| 16 |
* |
| 17 |
* @var array |
| 18 |
*/ |
| 19 |
protected $appends = ['id', 'name', 'email', 'permalink']; |
| 20 |
|
| 21 |
/** |
| 22 |
* The attributes that should be hidden for arrays. |
| 23 |
* |
| 24 |
* @var array |
| 25 |
*/ |
| 26 |
protected $hidden = ['ID', 'user_email', 'user_pass', 'display_name']; |
| 27 |
|
| 28 |
/** |
| 29 |
* Get the id of the user. |
| 30 |
* |
| 31 |
* @return bool |
| 32 |
*/ |
| 33 |
public function getIdAttribute() |
| 34 |
{ |
| 35 |
return (int) $this->attributes['ID']; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Get the name of the user. |
| 40 |
* |
| 41 |
* @return string |
| 42 |
*/ |
| 43 |
public function getNameAttribute() |
| 44 |
{ |
| 45 |
return $this->attributes['display_name']; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Get the email of the user. |
| 50 |
* |
| 51 |
* @return string |
| 52 |
*/ |
| 53 |
public function getEmailAttribute() |
| 54 |
{ |
| 55 |
return $this->attributes['user_email']; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Get the permalink of the user. |
| 60 |
* |
| 61 |
* @return string |
| 62 |
*/ |
| 63 |
public function getPermalinkAttribute() |
| 64 |
{ |
| 65 |
return get_edit_user_link($this->attributes['ID']); |
| 66 |
} |
| 67 |
} |
| 68 |
|