<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Traits\Auditable;

class UserTerms extends Model
{
    use HasFactory;
    use Auditable;
    
    protected $fillable = [
        'user_id',
        'term_id',
        'accepted',
        'accepted_at',
        'ip_address',
        'user_agent'
    ];
    
    protected $casts = [
        'accepted' => 'boolean',
        'accepted_at' => 'datetime'
    ];
    
    /**
     * Obtiene el usuario asociado a este registro
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }
    
    /**
     * Obtiene los términos y condiciones asociados a este registro
     */
    public function terms()
    {
        return $this->belongsTo(TermsAndConditions::class, 'term_id');
    }
}
