<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class DistProductImage extends Model
{
    use HasDateTimeFormatter;
    protected $table = 'dist_product_image';

    protected $casts = [
        'created_at' => 'datetime:Y-m-d H:i:s',
        'updated_at' => 'datetime:Y-m-d H:i:s',
    ];
    protected $fillable = [
        'image_url',
        'product_id',
        'order',
        'created_at',
        'updated_at'
        ];

    // 反向关联，属于某个产品
    public function product()
    {
        return $this->belongsTo(DistProduct::class, 'id');
    }

}
