62 lines
1.5 KiB
PHP
Executable File
62 lines
1.5 KiB
PHP
Executable File
<?php
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class ProductSerial extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'product_serials';
|
|
|
|
protected $fillable = [
|
|
'fornitore_id',
|
|
'product_id',
|
|
'legacy_scheda_id',
|
|
'customer_name',
|
|
'product_model',
|
|
'product_code',
|
|
'serial_number',
|
|
'serial_number_2',
|
|
'date_received',
|
|
'date_resold',
|
|
'purchase_date',
|
|
'purchase_price',
|
|
'purchase_currency',
|
|
'purchase_tax_rate',
|
|
'purchase_invoice_ref',
|
|
'purchase_invoice_line',
|
|
'internal_notes',
|
|
'source',
|
|
'source_reference',
|
|
];
|
|
|
|
protected $casts = [
|
|
'date_received' => 'datetime',
|
|
'date_resold' => 'datetime',
|
|
'purchase_date' => 'datetime',
|
|
'purchase_price' => 'decimal:2',
|
|
'purchase_tax_rate' => 'decimal:2',
|
|
'purchase_invoice_line' => 'integer',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
];
|
|
|
|
public function fornitore(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Fornitore::class, 'fornitore_id');
|
|
}
|
|
|
|
public function product(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Product::class, 'product_id');
|
|
}
|
|
|
|
public function legacyScheda(): BelongsTo
|
|
{
|
|
return $this->belongsTo(AssistenzaTecnorepairScheda::class, 'legacy_scheda_id');
|
|
}
|
|
}
|