<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class DriverCashbackTransaction extends Model
{
    const TYPE_TRIP_CASHBACK = 'trip_cashback';
    const TYPE_CONTINUITY_BONUS = 'continuity_bonus';
    const TYPE_RATING_BONUS = 'rating_bonus';
    const TYPE_REFERRAL_BONUS = 'referral_bonus';
    const TYPE_TRANSFER_TO_WALLET = 'transfer_to_wallet';
    const TYPE_EARLY_PENALTY = 'early_transfer_penalty';

    protected $fillable = [
        'cashback_wallet_id',
        'type',
        'amount',
        'balance_after',
        'source',
        'source_id',
        'description',
        'meta',
    ];

    protected $casts = [
        'amount' => 'decimal:2',
        'balance_after' => 'decimal:2',
        'meta' => 'array',
    ];

    public function wallet(): BelongsTo
    {
        return $this->belongsTo(DriverCashbackWallet::class, 'cashback_wallet_id');
    }
}
