👁 查看:NewspaperPage.php
路径:/home/boguraj1/public_html/epaper/app/Models/NewspaperPage.php
大小:900 B · 修改:2026-06-25 22:24:38 · 权限:0644 · 可写
<?php

namespace App\Models;

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

class NewspaperPage extends Model
{
    use HasFactory;

    protected $fillable = [
        'newspaper_id',
        'page_number',
        'title',
        'image_path',
        'thumbnail_path',
        'sort_order',
    ];

    public function newspaper()
    {
        return $this->belongsTo(Newspaper::class);
    }

    public function hotspots()
    {
        return $this->hasMany(Hotspot::class)->where('is_active', true);
    }

    public function getImageUrlAttribute()
    {
        return asset('storage/' . $this->image_path);
    }

    public function getThumbnailUrlAttribute()
    {
        if ($this->thumbnail_path) {
            return asset('storage/' . $this->thumbnail_path);
        }
        return asset('storage/' . $this->image_path);
    }
}