2024-09-09 15:29:31 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
2024-09-18 16:00:06 -07:00
|
|
|
use Database\Factories\ProductServiceFactory;
|
2024-09-09 15:29:31 -07:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
|
|
class ProductService extends Model
|
|
|
|
{
|
2024-09-18 16:00:06 -07:00
|
|
|
/** @use HasFactory<ProductServiceFactory> */
|
2024-09-09 15:29:31 -07:00
|
|
|
use HasFactory, SoftDeletes;
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
'order_id',
|
2024-09-19 11:52:04 -07:00
|
|
|
'service_file_id',
|
2024-09-09 15:29:31 -07:00
|
|
|
'service_type',
|
|
|
|
'placement',
|
2024-10-25 11:30:20 -04:00
|
|
|
'setup_amount',
|
2024-09-09 15:29:31 -07:00
|
|
|
'amount',
|
|
|
|
'amount_price',
|
2024-09-20 12:12:45 -07:00
|
|
|
'notes',
|
2024-09-09 15:29:31 -07:00
|
|
|
];
|
|
|
|
|
2024-11-05 18:07:19 -05:00
|
|
|
protected $appends = [
|
|
|
|
'service_details',
|
|
|
|
'price',
|
|
|
|
];
|
|
|
|
|
|
|
|
public function getPriceAttribute(): float
|
|
|
|
{
|
|
|
|
return number_format($this->amount * $this->amount_price, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getServiceDetailsAttribute(): string
|
|
|
|
{
|
|
|
|
$file = $this->serviceFile;
|
|
|
|
|
|
|
|
return $file->name.' '.$this->placement.' '.$file->width.' W '.$file->height.' H';
|
|
|
|
}
|
|
|
|
|
2024-09-18 16:00:06 -07:00
|
|
|
/**
|
|
|
|
* @return BelongsTo<Order, self>
|
|
|
|
*/
|
2024-09-09 15:29:31 -07:00
|
|
|
public function order(): BelongsTo
|
|
|
|
{
|
|
|
|
return $this->belongsTo(Order::class);
|
|
|
|
}
|
|
|
|
|
2024-09-18 16:00:06 -07:00
|
|
|
/**
|
2024-09-19 11:52:04 -07:00
|
|
|
* @return BelongsTo<ServiceFile, self>
|
2024-09-18 16:00:06 -07:00
|
|
|
*/
|
2024-09-19 11:52:04 -07:00
|
|
|
public function serviceFile(): BelongsTo
|
2024-09-09 15:29:31 -07:00
|
|
|
{
|
2024-09-19 11:52:04 -07:00
|
|
|
return $this->BelongsTo(ServiceFile::class);
|
2024-09-09 15:29:31 -07:00
|
|
|
}
|
|
|
|
}
|