User.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace App;
  3. use Illuminate\Notifications\Notifiable;
  4. use Illuminate\Contracts\Auth\MustVerifyEmail;
  5. use Illuminate\Foundation\Auth\User as Authenticatable;
  6. class User extends Authenticatable
  7. {
  8. protected $table = 'wechat_fans';
  9. use Notifiable;
  10. /**
  11. * The attributes that are mass assignable.
  12. *
  13. * @var array
  14. */
  15. // protected $fillable = [
  16. // 'name', 'email', 'password',
  17. // ];
  18. protected $guarded = [];
  19. /**
  20. * The attributes that should be hidden for arrays.
  21. *
  22. * @var array
  23. */
  24. protected $hidden = [
  25. 'password', 'remember_token',
  26. ];
  27. public function sclass()
  28. {
  29. return $this->belongsTo(Sclass::class, 'class_id');
  30. }
  31. public function grade()
  32. {
  33. return $this->belongsTo(Grade::class);
  34. }
  35. public function school()
  36. {
  37. return $this->belongsTo(School::class);
  38. }
  39. public function score()
  40. {
  41. return $this->hasMany(Score::class);
  42. }
  43. public function clocked()
  44. {
  45. return $this->hasMany(Clocked::class);
  46. }
  47. public function getSchoolTextAttribute()
  48. {
  49. return $this->school->name;
  50. }
  51. public function getGradeTextAttribute()
  52. {
  53. return $this->grade->name;
  54. }
  55. public function getClassTextAttribute()
  56. {
  57. return $this->sclass->name;
  58. }
  59. }