<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class SitePageTag extends Model
{
    use HasFactory;
    protected $table = 'site_pages_tag';

    public function pages($perPage = 10)
    {
        return $this->belongsToMany(
            SitePage::class,
            'site_pages_tag_relationship',
            'tag_id',
            'pages_id'
        )->where('status', 1)
            ->orderBy('post_date', 'desc')
            ->orderBy('id', 'desc')
            ->paginate($perPage); // 支持分页
    }
}
