21. Accessor 까지

This commit is contained in:
choibk 2025-12-07 12:45:41 +09:00
parent c6edbf93dd
commit a26047d608
3 changed files with 13 additions and 3 deletions

View File

@ -26,4 +26,14 @@ class StockLog extends Model
{
return $this->belongsTo(Product::class);
}
public function getChangeTypeLabelAttribute(): string
{
return $this->change_type === 'in' ? '입고' : '출고';
}
public function getSignedAmountAttribute(): int
{
return $this->change_type === 'in' ? (int) $this->change_amount : -(int) $this->change_amount;
}
}

View File

@ -51,7 +51,7 @@
<td>{{ $product->id }}</td>
<td>{{ $product->name }}</td>
<td>{{ $product->sku }}</td>
<td>{{ number_format($product->quantity) }} </td>
<td>{{ number_format($product->quantity) }}</td>
<td>{{ number_format($product->price) }} </td>
<td>
<div class="btn-group btn-group-sm" role="group">

View File

@ -22,8 +22,8 @@
<tr>
<td>{{ $log->created_at->format('Y-m-d H:i') }}</td>
<td>{{ ($log->product?->name ?? '삭제된 상품') }} ({{ $log->product?->sku ?? '-'}})</td>
<td>{{ $log->change_type }}</td>
<td>{{ $log->change_amount }} </td>
<td>{{ $log->change_type_label }}</td>
<td>{{ $log->signed_amount }}</td>
</tr>
@endforeach
</tbody>