Region.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Models;
  3. // use Illuminate\Contracts\Authenticate\MustVerifyEmail;
  4. use DateTimeInterface;
  5. use Illuminate\Database\Eloquent\Factories\HasFactory;
  6. use Illuminate\Database\Eloquent\Model;
  7. use Illuminate\Foundation\Auth\User as Authenticatable;
  8. use Illuminate\Notifications\Notifiable;
  9. use Laravel\Sanctum\HasApiTokens;
  10. use Tymon\JWTAuth\Contracts\JWTSubject;
  11. class Region extends Model
  12. {
  13. use HasFactory;
  14. // 设置表名
  15. protected $table = 'region';
  16. // 设置主键
  17. // public $primaryKey = 'id';
  18. /**
  19. * 自动生成时间戳
  20. */
  21. public $timestamps = FALSE;
  22. /**
  23. * 日期时间的存储格式
  24. *
  25. * @var string
  26. */
  27. // protected $dateFormat = 'Y-m-d H:i:s';
  28. /**
  29. * The attributes that are mass assignable.
  30. *
  31. * @var array<int, string>
  32. */
  33. protected $fillable = [];
  34. /**
  35. * The attributes that should be hidden for serialization.
  36. *
  37. * @var array<int, string>
  38. */
  39. protected $hidden = [];
  40. public function children()
  41. {
  42. return $this->hasMany(Region::class,'parentId','id');
  43. }
  44. public function service()
  45. {
  46. return $this->hasOne(ProjectServiceRelevancy::class,'service_id','id');
  47. }
  48. }