HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/topswtw.komma.pro/app/KommaApp/Shop/Orders/OrderProduct.php
<?php


namespace KommaApp\Shop\Orders;

use Illuminate\Database\Eloquent\Model;

class OrderProduct extends Model
{
    protected $table = 'order_products';

    protected $fillable = [
        'order_id',
        'internal_article_number',
        'pick_number',
        'title',
        'description',
        'delivery_time',
        'composition',
        'quantity',
        'price',
        'original_price',
        'discount_description',
        'discount_number_of_items_for_free',
        'tax_name',
        'tax_rate'
    ];

    public function getCompositionAsObject()
    {
        if(!$this->composition) return [];
        return json_decode($this->composition);
    }

    public function getPriceExVat()
    {
        return $this->price / (1 + ($this->tax_rate / 100));
    }

    public function getOriginalPriceExVat()
    {
        return $this->original_price / (1 + ($this->tax_rate / 100));
    }

    /**
     * Get product data for google e-commerce tracking.
     */
    public function googleEcommerceProductFieldObjectData()
    {
        return [
            'name' => $this->title,
            'price' => $this->price / 100,
            'quantity' => $this->quantity
        ];
    }
}