1. 實作倉儲管理系統 (Warehouse Management):包含總覽、庫存、調撥、機台庫存與補貨模組。 2. 建立倉儲相關資料結構:新增 warehouses, warehouse_stocks, stock_in_orders, stock_movements, transfer_orders, replenishment_orders 等資料表。 3. 優化商品管理 (Product Management) 介面:調整商品與類別管理的分頁、搜尋與編輯邏輯,並導入極簡奢華風 UI。 4. 增強遠端機台管理 (Remote Machine Management):優化機台清單、庫存監控與遠端出貨介面,提升載入效能。 5. 更新全站導覽選單 (Sidebar):整合倉儲管理入口,並修復側邊欄語法錯誤。 6. 標準化分頁組件 (Pagination):套用 luxury 奢華風分頁樣式。 7. 補齊多語系語系檔 (i18n):更新 zh_TW.json,包含倉儲與商品模組相關詞彙。
83 lines
1.5 KiB
PHP
83 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Warehouse;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\Traits\TenantScoped;
|
|
|
|
class StockMovement extends Model
|
|
{
|
|
use TenantScoped;
|
|
|
|
/**
|
|
* 此表為唯讀日誌,僅有 created_at
|
|
*/
|
|
public $timestamps = false;
|
|
|
|
protected $fillable = [
|
|
'company_id',
|
|
'warehouse_id',
|
|
'product_id',
|
|
'type',
|
|
'quantity',
|
|
'before_qty',
|
|
'after_qty',
|
|
'reference_type',
|
|
'reference_id',
|
|
'note',
|
|
'created_by',
|
|
'created_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'quantity' => 'integer',
|
|
'before_qty' => 'integer',
|
|
'after_qty' => 'integer',
|
|
'created_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* 異動類型對應中文
|
|
*/
|
|
public const TYPE_LABELS = [
|
|
'in' => 'Stock In',
|
|
'out' => 'Stock Out',
|
|
'adjust' => 'Adjustment',
|
|
'damage' => 'Damage',
|
|
'transfer_in' => 'Transfer In',
|
|
'transfer_out' => 'Transfer Out',
|
|
];
|
|
|
|
/**
|
|
* 所屬倉庫
|
|
*/
|
|
public function warehouse()
|
|
{
|
|
return $this->belongsTo(Warehouse::class);
|
|
}
|
|
|
|
/**
|
|
* 對應商品
|
|
*/
|
|
public function product()
|
|
{
|
|
return $this->belongsTo(\App\Models\Product\Product::class);
|
|
}
|
|
|
|
/**
|
|
* 操作人
|
|
*/
|
|
public function creator()
|
|
{
|
|
return $this->belongsTo(\App\Models\System\User::class, 'created_by');
|
|
}
|
|
|
|
/**
|
|
* 關聯單據(多態)
|
|
*/
|
|
public function reference()
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
}
|