Files
Verde-Web/app/Models/StoreSettlement.php

52 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Str;
class StoreSettlement extends Model
{
use HasFactory;
protected $fillable = [
'uuid',
'store_id',
'amount_centavos',
'payment_method',
'reference_number',
'notes',
'recorded_by_user_id',
'settled_at',
];
protected function casts(): array
{
return [
'amount_centavos' => 'integer',
'settled_at' => 'datetime',
];
}
protected static function booted(): void
{
static::creating(function (self $s): void {
if (empty($s->uuid)) {
$s->uuid = (string) Str::uuid();
}
});
}
public function store(): BelongsTo
{
return $this->belongsTo(PartnerStore::class, 'store_id');
}
public function recorder(): BelongsTo
{
return $this->belongsTo(User::class, 'recorded_by_user_id');
}
}