<?php

namespace App\Models;

use App\Traits\BelongsToOrganization;
use Illuminate\Database\Eloquent\Model;

class LoyaltyTransaction extends Model
{
    use BelongsToOrganization;
    protected $fillable = [
        'customer_id',
        'sale_id',
        'type',
        'points',
        'monetary_value',
        'description',
        'organization_id',
    ];

    protected function casts(): array
    {
        return [
            'points'         => 'integer',
            'monetary_value' => 'decimal:2',
        ];
    }

    public function customer()
    {
        return $this->belongsTo(Customer::class);
    }

    public function sale()
    {
        return $this->belongsTo(Sale::class);
    }
}
