SitePages.php 825 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\Model;
  5. class SitePages extends Model
  6. {
  7. use HasDateTimeFormatter;
  8. protected $table = 'site_pages';
  9. protected $fillable = [
  10. 'title',
  11. 'content',
  12. 'status',
  13. 'author',
  14. 'post_date',
  15. 'dist_id',
  16. 'cover_image',
  17. 'slug',
  18. 'seo_title',
  19. 'seo_keywords',
  20. 'seo_description',
  21. ];
  22. /**
  23. * 定义你的关联模型.
  24. *
  25. * @return BelongsToMany
  26. */
  27. public function pagesTag()
  28. {
  29. $pivotTable = 'site_pages_tag_relationship'; // 中间表
  30. $relatedModel = SitePagesTag::class; // 关联模型类名
  31. return $this->belongsToMany($relatedModel, $pivotTable, 'pages_id', 'tag_id');
  32. }
  33. }