User.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace App;
  3. use Laravel\Passport\HasApiTokens;
  4. use Illuminate\Notifications\Notifiable;
  5. use Illuminate\Database\Eloquent\SoftDeletes;
  6. use Illuminate\Foundation\Auth\User as Authenticatable;
  7. class User extends Authenticatable
  8. {
  9. use Notifiable, SoftDeletes, HasApiTokens;
  10. /**
  11. * The attributes that should be mutated to dates.
  12. *
  13. * @var array
  14. */
  15. protected $dates = ['deleted_at', 'email_verified_at', '2fa_setup_at'];
  16. /**
  17. * The attributes that are mass assignable.
  18. *
  19. * @var array
  20. */
  21. protected $fillable = [
  22. 'name', 'username', 'email', 'password',
  23. ];
  24. /**
  25. * The attributes that should be hidden for arrays.
  26. *
  27. * @var array
  28. */
  29. protected $hidden = [
  30. 'email', 'password', 'is_admin', 'remember_token',
  31. 'email_verified_at', '2fa_enabled', '2fa_secret',
  32. '2fa_backup_codes', '2fa_setup_at', 'deleted_at',
  33. 'updated_at'
  34. ];
  35. public function profile()
  36. {
  37. return $this->hasOne(Profile::class);
  38. }
  39. public function url()
  40. {
  41. return url(config('app.url').'/'.$this->username);
  42. }
  43. public function settings()
  44. {
  45. return $this->hasOne(UserSetting::class);
  46. }
  47. public function statuses()
  48. {
  49. return $this->hasManyThrough(
  50. Status::class,
  51. Profile::class
  52. );
  53. }
  54. public function filters()
  55. {
  56. return $this->hasMany(UserFilter::class);
  57. }
  58. public function receivesBroadcastNotificationsOn()
  59. {
  60. return 'App.User.'.$this->id;
  61. }
  62. }