<?php

namespace App\Models;

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

class Room extends Model
{
    use HasFactory;

    protected $fillable = [
        'boarding_house_id',
        'room_type',
        'price_per_month',
        'size',
        'is_available',
        'images', // Pastikan images ada di sini
    ];

    // --- BARU: Tambahkan blok casts ini ---
    protected $casts = [
        'images' => 'array',          // Mengubah array foto menjadi format yang bisa disimpan database
        'is_available' => 'boolean',  // Memastikan data toggle disimpan sebagai benar/salah
    ];
    // -------------------------------------

    public function boardingHouse()
    {
        return $this->belongsTo(BoardingHouse::class);
    }

    public function facilities()
    {
        return $this->belongsToMany(Facility::class);
    }
}
