Files
star-erp/app/Modules/Inventory/Models/InventoryTransferOrder.php
sky121113 e5edad4fd0
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Successful in 1m4s
Koori-ERP-Deploy-System / deploy-production (push) Has been skipped
style: 修正盤點與盤調畫面 Table Padding 並統一 UI 規範
2026-01-28 18:04:45 +08:00

67 lines
1.5 KiB
PHP

<?php
namespace App\Modules\Inventory\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use App\Modules\Core\Models\User;
class InventoryTransferOrder extends Model
{
use HasFactory;
protected $fillable = [
'doc_no',
'from_warehouse_id',
'to_warehouse_id',
'status',
'remarks',
'posted_at',
'created_by',
'updated_by',
'posted_by',
];
protected $casts = [
'posted_at' => 'datetime',
];
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
if (empty($model->doc_no)) {
$model->doc_no = 'TRF-' . date('YmdHis') . '-' . rand(100, 999);
}
});
}
public function fromWarehouse(): BelongsTo
{
return $this->belongsTo(Warehouse::class, 'from_warehouse_id');
}
public function toWarehouse(): BelongsTo
{
return $this->belongsTo(Warehouse::class, 'to_warehouse_id');
}
public function items(): HasMany
{
return $this->hasMany(InventoryTransferItem::class, 'transfer_order_id');
}
public function createdBy(): BelongsTo
{
return $this->belongsTo(User::class, 'created_by');
}
public function postedBy(): BelongsTo
{
return $this->belongsTo(User::class, 'posted_by');
}
}