1. 新增員工卡 (staff_cards) 與員工卡感應日誌 (staff_card_logs) 模型與遷移檔。 2. 實作 StaffCardController 與相關管理介面,支援狀態切換與 CRUD。 3. 擴充 routes/web.php 加入員工卡管理路由。 4. 更新 api-docs.php 文檔,補全 B012 (Unified Sync) 的商品同步回應範例。 5. 實作 PaymentTypeSeeder 並整合至 DatabaseSeeder 以標準化支付類型。 6. 優化銷售中心訂單標籤與倉庫機台庫存顯示邏輯。 7. 側邊欄選單加入員工卡管理入口。 8. 重構 TransactionService 以支援員工卡工作階段 (session_token) 驗證。
46 lines
906 B
PHP
46 lines
906 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\TenantScoped;
|
|
use App\Models\Machine\Machine;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class StaffCard extends Model
|
|
{
|
|
use TenantScoped;
|
|
|
|
protected $fillable = [
|
|
'company_id',
|
|
'employee_id',
|
|
'name',
|
|
'card_uid',
|
|
'status',
|
|
'notes',
|
|
'last_used_at',
|
|
'last_machine_id',
|
|
];
|
|
|
|
protected $casts = [
|
|
'last_used_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* 取得此卡片的刷卡紀錄
|
|
*/
|
|
public function logs(): HasMany
|
|
{
|
|
return $this->hasMany(StaffCardLog::class);
|
|
}
|
|
|
|
/**
|
|
* 取得最後一次使用的機台
|
|
*/
|
|
public function lastMachine(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Machine::class, 'last_machine_id');
|
|
}
|
|
}
|