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/netwerkbrabant.komma.pro/app/KommaApp/Orders/Models/OrderProduct.php
<?php


namespace App\KommaApp\Orders\Models;


use App\KommaApp\Events\Models\Event;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class OrderProduct extends Model
{

    protected $table = 'order_products';

    use SoftDeletes;

    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;


    protected $guarded = ['id', 'order_id'];

    /**
     * Get the order belonging to this order
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function order() : BelongsTo
    {
        return $this->belongsTo(Order::class);
    }

//    /**
//     * Get the belonging event to the product
//     *
//     * @return BelongsTo
//     */
//    public function event(): BelongsTo
//    {
//        return $this->belongsTo(Event::class, 'event_id');
//    }

    /**
     *  Get the belonging product
     */
    public function productable(): MorphTo
    {
        return $this->morphTo();
    }

    /**
     * Get the formatted price for with or without vat
     *
     * @param bool $vat
     * @param string $decPoint
     * @param string $thousandsSept
     * @param int $decimals
     * @return string
     */
    public function getFormattedPrice($vat = true, $decPoint = '.', $thousandsSept = '', $decimals = 2){
        if($vat) return number_format($this->price_including_vat / 100, $decimals, $decPoint, $thousandsSept);
        return number_format($this->price / 100, $decimals, $decPoint, $thousandsSept);
    }

}