<?php

namespace App\Models;

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

class Property_Types extends Model
{
    use HasFactory;
    use SoftDeletes;
    protected $table = 'property__types';

    protected $fillable = [
        // 'id_prop',
        'type_name',
        'status',
        'description',
    ];

    public function propertyType()
{
    return $this->belongsTo(Property_Types::class, 'id_prop_typ');
}

    public function properties()
{
    return $this->belongsToMany(
        Property::class,
        'property_x_types',
        'id_type',      // foreign key di tabel pivot untuk Property_Types
        'id_proper'     // foreign key di tabel pivot untuk Property
    )->withPivot('harga', 'jumlah_kamar', 'lantai')
     ->withTimestamps();
}
    
}
