44 lines
996 B
PHP
44 lines
996 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Modules\Sales\Models;
|
||
|
|
|
||
|
|
use App\Modules\Core\Models\User;
|
||
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||
|
|
|
||
|
|
class SalesImportBatch extends Model
|
||
|
|
{
|
||
|
|
use HasFactory;
|
||
|
|
|
||
|
|
protected $table = 'sales_import_batches';
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'import_date',
|
||
|
|
'total_quantity',
|
||
|
|
'total_amount',
|
||
|
|
'status',
|
||
|
|
'imported_by',
|
||
|
|
'confirmed_at',
|
||
|
|
'note',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'import_date' => 'date',
|
||
|
|
'confirmed_at' => 'datetime',
|
||
|
|
'total_quantity' => 'decimal:4',
|
||
|
|
'total_amount' => 'decimal:4',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function items(): HasMany
|
||
|
|
{
|
||
|
|
return $this->hasMany(SalesImportItem::class, 'batch_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function importer(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(User::class, 'imported_by');
|
||
|
|
}
|
||
|
|
}
|