You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
topnotch_website/app/Models/ProductService.php

60 lines
1.3 KiB
PHTML

3 months ago
<?php
namespace App\Models;
use Database\Factories\ProductServiceFactory;
3 months ago
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
{
/** @use HasFactory<ProductServiceFactory> */
3 months ago
use HasFactory, SoftDeletes;
protected $fillable = [
'order_id',
2 months ago
'service_file_id',
3 months ago
'service_type',
'placement',
'setup_amount',
3 months ago
'amount',
'amount_price',
'notes',
3 months ago
];
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';
}
/**
* @return BelongsTo<Order, self>
*/
3 months ago
public function order(): BelongsTo
{
return $this->belongsTo(Order::class);
}
/**
2 months ago
* @return BelongsTo<ServiceFile, self>
*/
2 months ago
public function serviceFile(): BelongsTo
3 months ago
{
2 months ago
return $this->BelongsTo(ServiceFile::class);
3 months ago
}
}