<?php

namespace App\Models;

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

class ScreenPrintEntry extends Model
{
    use HasFactory;

    protected $fillable = [
        'quote_id',
        'quantity',
        'logo',
        'placement',
        'width',
        'height',
        'color_amount',
        'setup_amount',
        'run_charge',
        'color_change',
        'color_match',
        'flash',
        'fleece',
        'poly_ink',
        'artwork_fee',
        'repacking_fee',
        'notes',
    ];

    protected $appends = [
        'total_price',
    ];

    protected function getTotalPriceAttribute(): float
    {
        $perUnitTotals = ($this->flash + $this->fleece + $this->poly_ink + $this->run_charge + $this->repacking_fee) * $this->quantity ?? 0;

        return $perUnitTotals + $this->artwork_fee + $this->color_change + $this->color_match;
    }

    public function quote(): BelongsTo
    {
        return $this->belongsTo(Quote::class);
    }
}