User.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Models;
  3. // use Illuminate\Contracts\Auth\MustVerifyEmail;
  4. use Illuminate\Database\Eloquent\Factories\HasFactory;
  5. use Illuminate\Foundation\Auth\User as Authenticatable;
  6. use Illuminate\Notifications\Notifiable;
  7. use Laravel\Sanctum\HasApiTokens;
  8. class User extends Authenticatable
  9. {
  10. use HasApiTokens, HasFactory, Notifiable;
  11. protected $table = 'fcf_users';
  12. public $timestamps = false;
  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. 'username',
  23. 'firstname',
  24. 'lastname'
  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. 'email_verified_at' => 'datetime',
  42. 'password' => 'hashed',
  43. ];
  44. public function group()
  45. {
  46. $rel = \App\Models\UserUserGroup::where('user_id', $this->id)->first();
  47. if ($rel)
  48. {
  49. if ($rel->group_id > 0)
  50. return \App\Models\UserGroup::findOrFail($rel->group_id)->name;
  51. else
  52. return "";
  53. }
  54. else
  55. return "";
  56. }
  57. }