Files
BarangaySystem/app/Models/GlobalTransaction.php
2026-06-06 18:43:00 +08:00

73 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Models;
use App\Models\Model;
use App\Models\User;
use App\Models\Market\Product;
use App\Models\Market\Store;
use App\Enums\Market\ProductTransactionType;
use App\Enums\Market\TransactionFlow;
class GlobalTransaction extends Model
{
protected ?string $table = 'global_transactions';
protected string $primaryKey = 'id';
public bool $incrementing = true;
protected string $keyType = 'int';
protected array $fillable = [
'hashkey',
'user_id',
'amount',
'type',
'status',
'description',
'product_id',
'store_id',
'flow',
'created_by',
'updated_by',
];
protected array $casts = [
'amount' => 'decimal:2',
'type' => ProductTransactionType::class,
'user_id' => 'integer',
'product_id' => 'integer',
'store_id' => 'integer',
'flow' => TransactionFlow::class,
'created_by' => 'integer',
'updated_by' => 'integer',
];
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
public function product()
{
return $this->belongsTo(Product::class, 'product_id');
}
public function store()
{
return $this->belongsTo(Store::class, 'store_id');
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
}