Article.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. * The attributes that are mass assignable.
  15. */
  16. protected array $fillable = [];
  17. /**
  18. * The attributes that should be cast to native types.
  19. */
  20. protected array $casts = [];
  21. /**
  22. * 定义与分类的多对一关系
  23. */
  24. public function category()
  25. {
  26. return $this->belongsTo(Category::class, 'catid', 'id');
  27. }
  28. /**
  29. * 定义与分类的多对一关系
  30. */
  31. public function websiteCategory()
  32. {
  33. return $this->belongsTo(WebsiteCategory::class, 'catid', 'category_id');
  34. }
  35. /**
  36. * 定义与分类的多对一关系
  37. */
  38. public function aricleIgnore()
  39. {
  40. return $this->belongsTo(ArticleIgnore::class, 'id', 'article_id');
  41. }
  42. /**
  43. * 定义与分类的一对一关系
  44. */
  45. public function user()
  46. {
  47. return $this->hasOne(User::class, 'id', 'admin_user_id');
  48. }
  49. }