<?php

namespace App\Models;

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

class AppointmentTag extends Model
{
    use HasFactory;
    use Auditable;

    
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name',
        'color',
        'active',
        'order'
    ];
    
    /**
     * The attributes that should be cast.
     *
     * @var array
     */
    protected $casts = [
        'active' => 'boolean',
        'order' => 'integer'
    ];
    
    /**
     * The appointments that belong to the tag.
     */
    public function appointments()
    {
        return $this->belongsToMany(Appointment::class, 'appointment_appointment_tag');
    }
}
