User.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace App\Models;
  3. // use Illuminate\Contracts\Auth\MustVerifyEmail;
  4. use Illuminate\Database\Eloquent\Factories\HasFactory;
  5. use Illuminate\Database\Eloquent\Relations\HasMany;
  6. use Illuminate\Foundation\Auth\User as Authenticatable;
  7. use Illuminate\Notifications\Notifiable;
  8. class User extends Authenticatable
  9. {
  10. /** @use HasFactory<\Database\Factories\UserFactory> */
  11. use HasFactory, Notifiable;
  12. /**
  13. * The attributes that are mass assignable.
  14. *
  15. * @var list<string>
  16. */
  17. protected $fillable = [
  18. 'name',
  19. 'email',
  20. 'password',
  21. ];
  22. /**
  23. * The attributes that should be hidden for serialization.
  24. *
  25. * @var list<string>
  26. */
  27. protected $hidden = [
  28. 'password',
  29. 'remember_token',
  30. ];
  31. /**
  32. * Get the attributes that should be cast.
  33. *
  34. * @return array<string, string>
  35. */
  36. protected function casts(): array
  37. {
  38. return [
  39. 'email_verified_at' => 'datetime',
  40. 'password' => 'hashed',
  41. ];
  42. }
  43. public function chats(): HasMany
  44. {
  45. return $this->hasMany(Chat::class)->orderBy('created_at', 'desc');
  46. }
  47. }