<?php

namespace App\Models;

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

class Receipt extends Model
{
    use HasFactory;

    protected $fillable = [
        'record_id',
        'member_id',
        'supplier_id',
        'causal_id',
        'payment_method_id',
        'number',
        'date',
        'month',
        'year',
        'type',
        'amount',
        'commercial',
        'status',
        'parent'
    ];

    public function rows()
    {
        return $this->hasMany(ReceiptRow::class, 'receip_id', 'id');
    }

    public function record()
    {
        return $this->belongsTo(Record::class);
    }

    public function member()
    {
        return $this->belongsTo(Member::class);
    }

    public function supplier()
    {
        return $this->belongsTo(Supplier::class);
    }

    public function causal()
    {
        return $this->belongsTo(Causal::class);
    }

    public function payment_method()
    {
        return $this->belongsTo(PaymentMethod::class);
    }

}

