<?php

namespace App\Models;

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

class Price extends Model
{
    use HasFactory;
    protected $fillable = [
        'status',
        'price_product_id',
        'price_country_id',
    ];

    public function product_data()
    {
        return $this->belongsTo(PriceProduct::class, 'price_product_id');
    }

    public function price_data(){
        return $this->hasMany(PriceData::class);
    }

    public function country_data()
    {
        return $this->belongsTo(PriceCountry::class, 'price_country_id');
    }
    public function getCreatedAtAttribute($value)
    {
        return \Carbon\Carbon::parse($value)->format('d/m/Y H:i a');
    }

    // Accessor to format the updated_at field
    public function getUpdatedAtAttribute($value)
    {
        return \Carbon\Carbon::parse($value)->format('d/m/Y H:i a');
    }
}
