暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

User.php 1.2KB

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