Country.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * 国家/地区.
  6. *
  7. * @property string $code ISO国家代码
  8. * @property string $name 名称
  9. * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Node[] $nodes
  10. * @property-read int|null $nodes_count
  11. * @method static \Illuminate\Database\Eloquent\Builder|Country newModelQuery()
  12. * @method static \Illuminate\Database\Eloquent\Builder|Country newQuery()
  13. * @method static \Illuminate\Database\Eloquent\Builder|Country query()
  14. * @method static \Illuminate\Database\Eloquent\Builder|Country whereCode($value)
  15. * @method static \Illuminate\Database\Eloquent\Builder|Country whereName($value)
  16. * @mixin \Eloquent
  17. */
  18. class Country extends Model
  19. {
  20. public $timestamps = false;
  21. public $incrementing = false;
  22. protected $table = 'country';
  23. protected $primaryKey = 'code';
  24. protected $keyType = 'string';
  25. protected $guarded = [];
  26. public function nodes()
  27. {
  28. return $this->hasMany(Node::class, 'country_code');
  29. }
  30. }