User.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Foundation\Auth\User as Authenticatable;
  4. use Illuminate\Notifications\Notifiable;
  5. use Illuminate\Database\Eloquent\Factories\HasFactory;
  6. use Laravel\Sanctum\HasApiTokens;
  7. class User extends Authenticatable
  8. {
  9. use HasApiTokens, HasFactory, Notifiable;
  10. protected $table = 'users';
  11. protected $guard_name = 'api';
  12. protected $primaryKey = 'id';
  13. /**
  14. * The attributes that are mass assignable.
  15. *
  16. * @var array<int, string>
  17. */
  18. protected $fillable = [
  19. 'name',
  20. 'account',
  21. 'password',
  22. 'email',
  23. 'role',
  24. 'unit',
  25. ];
  26. /**
  27. * The attributes that should be hidden for serialization.
  28. *
  29. * @var array<int, string>
  30. */
  31. protected $hidden = [
  32. 'password',
  33. 'remember_token',
  34. ];
  35. /**
  36. * The attributes that should be cast.
  37. *
  38. * @var array<string, string>
  39. */
  40. protected $casts = [
  41. 'password' => 'hashed',
  42. ];
  43. protected static function booted()
  44. {
  45. static::creating(function ($user) {
  46. \Log::info('Creating user: ' . $user->id);
  47. });
  48. static::created(function ($user) {
  49. \Log::info('User created: ' . $user->id);
  50. });
  51. }
  52. }