<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Visit extends Model
{
    protected $fillable = [
        'user_id',
        'visit_date',
        'spend_amount',
        'points_awarded',
        'recorded_by',
        'notes',
    ];

    protected function casts(): array
    {
        return [
            'visit_date'   => 'date',
            'spend_amount' => 'decimal:2',
        ];
    }

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

    public function recordedBy()
    {
        return $this->belongsTo(Admin::class, 'recorded_by');
    }

    public function transaction()
    {
        return $this->hasOne(PointsTransaction::class);
    }
}
