<?php

namespace App\Models;

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

class CreditPurchase extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id', 'credits_requested', 'amount_tzs', 'payment_method',
        'payment_phone', 'reference', 'status', 'admin_note', 'completed_at',
    ];

    protected function casts(): array
    {
        return ['completed_at' => 'datetime'];
    }

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    /** Packages available for purchase */
    public static function packages(): array
    {
        return [
            ['credits' => 1,  'amount' => 1000],
            ['credits' => 5,  'amount' => 4500],
            ['credits' => 10, 'amount' => 8000],
        ];
    }
}
