User.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Models\Member;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. use Illuminate\Foundation\Auth\User as Authenticatable;
  6. use Illuminate\Notifications\Notifiable;
  7. use Laravel\Sanctum\HasApiTokens;
  8. use Spatie\Permission\Traits\HasRoles;
  9. class User extends Authenticatable
  10. {
  11. use HasApiTokens, HasFactory, Notifiable, SoftDeletes;
  12. protected $table = 'member_users';
  13. /**
  14. * The attributes that are mass assignable.
  15. *
  16. * @var array<int, string>
  17. */
  18. protected $fillable = [];
  19. protected $guarded = [];
  20. /**
  21. * The attributes that should be hidden for serialization.
  22. *
  23. * @var array<int, string>
  24. */
  25. protected $hidden = [
  26. 'password'
  27. ];
  28. /**
  29. * Get the attributes that should be cast.
  30. *
  31. * @return array<string, string>
  32. */
  33. protected function casts(): array
  34. {
  35. return [
  36. 'password' => 'hashed',
  37. 'login_date' => 'datetime'
  38. ];
  39. }
  40. public function getBalanceAttribute($value)
  41. {
  42. return number_format($value / 100, 2, '.', '');
  43. }
  44. public function coach(): \Illuminate\Database\Eloquent\Relations\HasOne
  45. {
  46. return $this->hasOne(\App\Models\Coach\User::class, 'user_id');
  47. }
  48. }