<?php

namespace App\Models;

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

class SharedPurchase extends Model
{
    public $timestamps = false;
    public $incrementing = false;
    protected $keyType = 'string';

    protected $fillable = [
        'id',
        'space_id',
        'name',
        'emoji',
        'status',
        'notes',
        'target_amount',
        'created_at',
    ];

    protected $casts = [
        'target_amount' => 'float',
        'created_at' => 'date',
    ];

    public function members(): BelongsToMany
    {
        return $this->belongsToMany(Person::class, 'shared_purchase_members', 'shared_purchase_id', 'person_id');
    }
}

