<?php

namespace App\Models;

use App\Services\Repositories\CategoryRepository;
use App\Services\Repositories\ProductRepository;
use Illuminate\Database\Eloquent\Model;

class OrderProduct extends Model
{
    public $timestamps = false;

    protected $fillable = [
        'count',
        'product_cost',
        'total',
        'order_id',
        'product_id',
    ];

    public function getProductAttribute()
    {
        $product = (new ProductRepository())->getItem($this->product_id);
        return $product;
    }

    public function getproductCategoryAttribute()
    {
        $category = (new CategoryRepository())->getItem($this->product->category->id);
        return $category;
    }

}
