<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

/**
 * @property int $id
 * @property string $description
 * @property string $improvement_type
 * @property bool $is_active
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 * @property \Carbon\Carbon|null $deleted_at
 */
class ImprovementType extends Model
{
  use HasFactory, SoftDeletes;

  protected $table = 'improvement_types';

  protected $guarded = [
    'id',
  ];

  protected $casts = [
    'created_at' => 'datetime',
    'updated_at' => 'datetime',
    'deleted_at' => 'datetime',
    'is_active' => 'boolean',
  ];

  protected $fillable = [
    'description',
    'improvement_type',
    'is_active',
  ];

  public function reviews(): BelongsToMany
  {
    return $this->belongsToMany(
      Review::class,
      'review_improvements',
      'improvement_id',
      'review_id'
    );
  }
}
