User1.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\Models;
  3. // use Illuminate\Contracts\Authenticate\MustVerifyEmail;
  4. use DateTimeInterface;
  5. use Illuminate\Database\Eloquent\Factories\HasFactory;
  6. use Illuminate\Foundation\Auth\User as Authenticatable;
  7. use Illuminate\Notifications\Notifiable;
  8. use Laravel\Sanctum\HasApiTokens;
  9. use Tymon\JWTAuth\Contracts\JWTSubject;
  10. class User1 extends Authenticatable implements JWTSubject
  11. {
  12. use HasApiTokens, HasFactory, Notifiable;
  13. /**
  14. * The attributes that are mass assignable.
  15. *
  16. * @var array<int, string>
  17. */
  18. protected $fillable = [
  19. 'name',
  20. 'email',
  21. 'password',
  22. ];
  23. /**
  24. * The attributes that should be hidden for serialization.
  25. *
  26. * @var array<int, string>
  27. */
  28. protected $hidden = [
  29. 'password',
  30. 'remember_token',
  31. ];
  32. /**
  33. * The attributes that should be cast.
  34. *
  35. * @var array<string, string>
  36. */
  37. protected $casts = [
  38. 'email_verified_at' => 'datetime',
  39. 'password' => 'hashed',
  40. ];
  41. protected function serializeDate(DateTimeInterface $date): string
  42. {
  43. return $date->format('Y-m-d H:i:s');
  44. }
  45. /**
  46. * @inheritDoc
  47. */
  48. public function getJWTIdentifier()
  49. {
  50. return $this->getKey();
  51. }
  52. /**
  53. * @inheritDoc
  54. */
  55. public function getJWTCustomClaims(): array
  56. {
  57. return [];
  58. }
  59. }