Article.php 802 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Model;
  4. use Hyperf\DbConnection\Model\Model;
  5. /**
  6. */
  7. class Article extends Model
  8. {
  9. /**
  10. * The table associated with the model.
  11. */
  12. protected ?string $table = 'article';
  13. /**
  14. * 定义与分类的多对一关系
  15. */
  16. public function category()
  17. {
  18. return $this->belongsTo(Category::class, 'category_id', 'id');
  19. }
  20. /**
  21. * 定义与分类的多对一关系
  22. */
  23. public function websiteCategory()
  24. {
  25. return $this->belongsTo(WebsiteCategory::class, 'category_id', 'id');
  26. }
  27. /**
  28. * The attributes that are mass assignable.
  29. */
  30. protected array $fillable = [];
  31. /**
  32. * The attributes that should be cast to native types.
  33. */
  34. protected array $casts = [];
  35. }