<?php

namespace App\Models;

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

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

    protected $fillable = [
        'id',
        'shared_list_id',
        'item_text',
        'amount',
        'paid_by_person_id',
        'expense_id',
        'done',
        'added_by_person_id',
    ];

    protected $casts = [
        'done' => 'bool',
        'amount' => 'float',
    ];

    public function list(): BelongsTo
    {
        return $this->belongsTo(SharedList::class, 'shared_list_id', 'id');
    }

    public function paidBy(): BelongsTo
    {
        return $this->belongsTo(Person::class, 'paid_by_person_id', 'id');
    }

    public function addedBy(): BelongsTo
    {
        return $this->belongsTo(Person::class, 'added_by_person_id', 'id');
    }

    public function expense(): BelongsTo
    {
        return $this->belongsTo(Expense::class, 'expense_id', 'id');
    }
}

