All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 55s
54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Finance\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class UtilityFee extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* 此公共事業費的附件
|
|
*/
|
|
public function attachments()
|
|
{
|
|
return $this->hasMany(UtilityFeeAttachment::class);
|
|
}
|
|
|
|
// 狀態常數
|
|
const STATUS_PENDING = 'pending';
|
|
const STATUS_PAID = 'paid';
|
|
const STATUS_OVERDUE = 'overdue';
|
|
|
|
protected $fillable = [
|
|
'transaction_date',
|
|
'due_date',
|
|
'category',
|
|
'amount',
|
|
'payment_status',
|
|
'invoice_number',
|
|
'description',
|
|
];
|
|
|
|
protected $casts = [
|
|
'transaction_date' => 'date:Y-m-d',
|
|
'due_date' => 'date:Y-m-d',
|
|
'amount' => 'decimal:2',
|
|
];
|
|
|
|
public function tapActivity(\Spatie\Activitylog\Contracts\Activity $activity, string $eventName)
|
|
{
|
|
$snapshot = [
|
|
'transaction_date' => $this->transaction_date?->format('Y-m-d'),
|
|
'due_date' => $this->due_date?->format('Y-m-d'),
|
|
'category' => $this->category,
|
|
'amount' => $this->amount,
|
|
'payment_status' => $this->payment_status,
|
|
'invoice_number' => $this->invoice_number,
|
|
];
|
|
$activity->properties = $activity->properties->put('snapshot', $snapshot);
|
|
}
|
|
}
|