<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;

class Pay extends Model
{
    use LogsActivity;

    public function getActivitylogOptions(): LogOptions
    {
        return LogOptions::defaults()
            ->useLogName('pay')
            ->logOnly(['pay_type_id', 'user_id', 'pay_date', 'amount', 'status'])
            ->logOnlyDirty();
    }
    
    // (Opcional) Personalize quais eventos logar. Padrão: created, updated, deleted
    protected static $recordEvents = ['created', 'updated', 'deleted'];

    // // (Opcional) Defina quais atributos monitorar. Padrão: todos ('*')
    protected static $logAttributes = ['pay_type_id','user_id', 'pay_date', 'amount', 'status'];

    // // (Opcional) Ignore atributos sensíveis se estiver logando todos
    // protected static $logAttributesToIgnore = ['password', 'remember_token'];

    // // (Opcional) Altere o nome do log
    // protected static $logName = 'posts_system';

    protected $table = 'pay';
    protected $with = ['user.people', 'bank', 'payType'];
    protected $fillable = 
    [
        'id',
        'pay_type_id',
        'company_id',
        'user_id',
        'pay_date',
        'amount',
        'id_card_number',
        'bank_id',
        'reference',
        'status',
        'url_pay_imagen',
        'created_at',
        'updated_at',
        'is_full_input',
        'level_input'
    ];
    public function payType()
    {
        return $this->belongsTo(Pay_type::class, 'pay_type_id');
    }
    public function company()
    {
        return $this->belongsTo(Company::class, 'company_id');
    }
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }
    public function bank()
    {
        return $this->belongsTo(Bank::class, 'bank_id');
    }
    public function payDetails()
    {
        return $this->hasMany(Pay_details::class, 'pay_id');
    }

    
}
