User.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. use App\Util\RateLimit\User as UserRateLimit;
  8. class User extends Authenticatable
  9. {
  10. use Notifiable, SoftDeletes, HasApiTokens, UserRateLimit;
  11. /**
  12. * The attributes that should be mutated to dates.
  13. *
  14. * @var array
  15. */
  16. protected $dates = ['deleted_at', 'email_verified_at', '2fa_setup_at'];
  17. /**
  18. * The attributes that are mass assignable.
  19. *
  20. * @var array
  21. */
  22. protected $fillable = [
  23. 'name', 'username', 'email', 'password',
  24. ];
  25. /**
  26. * The attributes that should be hidden for arrays.
  27. *
  28. * @var array
  29. */
  30. protected $hidden = [
  31. 'email', 'password', 'is_admin', 'remember_token',
  32. 'email_verified_at', '2fa_enabled', '2fa_secret',
  33. '2fa_backup_codes', '2fa_setup_at', 'deleted_at',
  34. 'updated_at'
  35. ];
  36. public function profile()
  37. {
  38. return $this->hasOne(Profile::class);
  39. }
  40. public function url()
  41. {
  42. return url(config('app.url').'/'.$this->username);
  43. }
  44. public function settings()
  45. {
  46. return $this->hasOne(UserSetting::class);
  47. }
  48. public function statuses()
  49. {
  50. return $this->hasManyThrough(
  51. Status::class,
  52. Profile::class
  53. );
  54. }
  55. public function filters()
  56. {
  57. return $this->hasMany(UserFilter::class, 'user_id', 'profile_id');
  58. }
  59. public function receivesBroadcastNotificationsOn()
  60. {
  61. return 'App.User.'.$this->id;
  62. }
  63. public function devices()
  64. {
  65. return $this->hasMany(UserDevice::class);
  66. }
  67. public function storageUsedKey()
  68. {
  69. return 'profile:storage:used:' . $this->id;
  70. }
  71. public function accountLog()
  72. {
  73. return $this->hasMany(AccountLog::class);
  74. }
  75. public function interstitials()
  76. {
  77. return $this->hasMany(AccountInterstitial::class);
  78. }
  79. }