1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace App\Models;
- use Dcat\Admin\Traits\HasDateTimeFormatter;
- use Illuminate\Database\Eloquent\Model;
- class SitePages extends Model
- {
- use HasDateTimeFormatter;
- protected $table = 'site_pages';
- protected $fillable = [
- 'title',
- 'content',
- 'status',
- 'author',
- 'post_date',
- 'dist_id',
- 'cover_image',
- 'slug',
- 'seo_title',
- 'seo_keywords',
- 'seo_description',
- 'page_type',
- 'template_file'
- ];
- /**
- * 定义你的关联模型.
- *
- * @return BelongsToMany
- */
- public function pagesTag()
- {
- $pivotTable = 'site_pages_tag_relationship'; // 中间表
- $relatedModel = SitePagesTag::class; // 关联模型类名
- return $this->belongsToMany($relatedModel, $pivotTable, 'pages_id', 'tag_id');
- }
- }
|