<?php

namespace App\Models;

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

class LokasiTps extends Model
{
    use HasFactory;

    protected $table = 'lokasi_tps';
    protected $primaryKey = 'id_tps';
    protected $keyType = 'int';
    public $incrementing = true;
    public $timestamps = false;

    protected $fillable = [
        'kategori_tps_id',
        'nama_tps',
        'alamat_tps',
        'status_tps',
        'tahun_pembuatan',
        'kapasitas_tps',
        'latitude',
        'longitude',
        'foto_tps',
    ];

    /**
     * Relasi ke tabel kategori_tps
     * One TPS belongs to one kategori
     */
    public function kategori()
    {
        return $this->belongsTo(KategoriTps::class, 'kategori_tps_id');
    }

    /**
     * Relasi ke tabel aduan_tps
     * One TPS has many aduan
     */
    public function aduan()
    {
        return $this->hasMany(AduanTps::class, 'lokasi_tps_id');
    }
}
