TermCategory.php 612 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  5. /**
  6. * 术语的一个百科分类(`term_categories` 表)。由正文里的 `{{category|…}}` 抽出,
  7. * v3 写入术语时整体重建,不单独增删。
  8. */
  9. class TermCategory extends Model
  10. {
  11. protected $fillable = ['term_guid', 'category', 'position'];
  12. protected function casts(): array
  13. {
  14. return ['position' => 'integer'];
  15. }
  16. public function term(): BelongsTo
  17. {
  18. return $this->belongsTo(DhammaTerm::class, 'term_guid', 'guid');
  19. }
  20. }