52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Modules\Sales\Models;
|
||
|
|
|
||
|
|
use App\Modules\Inventory\Models\Product;
|
||
|
|
use App\Modules\Inventory\Models\Warehouse;
|
||
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
|
||
|
|
class SalesImportItem extends Model
|
||
|
|
{
|
||
|
|
use HasFactory;
|
||
|
|
|
||
|
|
protected $table = 'sales_import_items';
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'batch_id',
|
||
|
|
'machine_id',
|
||
|
|
'slot',
|
||
|
|
'product_code',
|
||
|
|
'product_id',
|
||
|
|
'transaction_at',
|
||
|
|
'transaction_serial',
|
||
|
|
'quantity',
|
||
|
|
'amount',
|
||
|
|
'original_status',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'transaction_at' => 'datetime',
|
||
|
|
'quantity' => 'integer',
|
||
|
|
'amount' => 'decimal:4',
|
||
|
|
'original_status' => 'string',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function batch(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(SalesImportBatch::class, 'batch_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function product(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Product::class, 'product_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function warehouse(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Warehouse::class, 'machine_id', 'code');
|
||
|
|
}
|
||
|
|
}
|