User.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App;
  3. use App\Notifications\Email\ResetPassword as ResetPasswordNotification;
  4. use App\Notifications\Email\VerifyEmail as VerifyEmailNotification;
  5. use Illuminate\Contracts\Auth\MustVerifyEmail;
  6. use Illuminate\Database\Eloquent\SoftDeletes;
  7. use Illuminate\Foundation\Auth\User as Authenticatable;
  8. use Illuminate\Notifications\Notifiable;
  9. use Laratrust\Traits\LaratrustUserTrait;
  10. class User extends Authenticatable implements MustVerifyEmail
  11. {
  12. use Notifiable, SoftDeletes, LaratrustUserTrait;
  13. /**
  14. * The attributes that are mass assignable.
  15. *
  16. * @var array
  17. */
  18. protected $fillable = [
  19. 'name', 'username', 'parent_id', 'is_superuser', 'is_banned', 'two_factor_status', 'mobile', 'email', 'password'
  20. ];
  21. /**
  22. * The attributes that should be hidden for arrays.
  23. *
  24. * @var array
  25. */
  26. protected $hidden = [
  27. 'password', 'remember_token',
  28. ];
  29. /**
  30. * The attributes that should be cast to native types.
  31. *
  32. * @var array
  33. */
  34. protected $casts = [
  35. 'email_verified_at' => 'datetime',
  36. ];
  37. /**
  38. * @return mixed
  39. */
  40. public function isSuperUser()
  41. {
  42. return $this->is_supperuser;
  43. }
  44. /**
  45. * @return mixed
  46. */
  47. public function isBanned()
  48. {
  49. return $this->is_banned;
  50. }
  51. /**
  52. * Send the password reset notification.
  53. *
  54. * @param string $token
  55. * @return void
  56. */
  57. public function sendPasswordResetNotification($token)
  58. {
  59. $this->notify(new ResetPasswordNotification($token));
  60. }
  61. /**
  62. * Send the email verification notification.
  63. *
  64. * @return void
  65. */
  66. public function sendEmailVerificationNotification()
  67. {
  68. $this->notify(new VerifyEmailNotification);
  69. }
  70. }