<?php

namespace App\Models;

use App\Models\Concerns\HasOwnerScope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Goal extends Model
{
    use HasOwnerScope;

    protected $fillable = [
        'user_id',
        'external_id',
        'name',
        'target_amount',
        'saved_amount',
        'icon',
        'deadline',
        'monthly_contribution',
        'priority',
    ];

    protected function casts(): array
    {
        return [
            'target_amount' => 'float',
            'saved_amount' => 'float',
            'deadline' => 'date',
            'monthly_contribution' => 'float',
        ];
    }

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