<?php

namespace App\Models;

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

class BookingFoto extends Model
{
    use HasFactory;

    protected $table = 'booking_fotos';
    protected $primaryKey = 'id_booking';

    protected $fillable = [
        'no_invoice',
        'id_pelanggan',
        'id_paket',
        'tgl_booking',
        'jam_mulai',
        'jam_selesai',
        'total_bayar',
        'bukti_bayar',
        'status_booking',
    ];

    public function pelanggan()
    {
        return $this->belongsTo(Pelanggan::class, 'id_pelanggan');
    }

    public function paketFoto()
    {
        return $this->belongsTo(PaketFoto::class, 'id_paket');
    }

    public function detailAdditional()
    {

        return $this->hasMany(DetailAdditional::class, 'id_booking', 'id_booking');
    }
    public function getStatusLabelAttribute()
    {
        // Mapping status ke class subtle dan teks
        $statusMap = [
            'menunggu_verifikasi' => [
                'class' => 'bg-info-subtle', // text-emphasis agar kontras
                'text'  => 'Menunggu Verifikasi'
            ],
            'diterima' => [
                'class' => 'bg-warning-subtle ',
                'text'  => 'Diterima'
            ],
            'selesai' => [
                'class' => 'bg-success-subtle',
                'text'  => 'Selesai'
            ],
            'dibatalkan' => [
                'class' => 'bg-info-subtle ',
                'text'  => 'Dibatalkan'
            ],
            'ditolak' => [
                'class' => 'bg-danger-subtle',
                'text'  => 'Ditolak'
            ],
        ];

        // Mengambil data berdasarkan status_transaksi, default ke secondary jika tidak ada
        return (object) ($statusMap[$this->status_booking] ?? [
            'class' => 'bg-secondary-subtle text-secondary',
            'text'  => 'Unknown'
        ]);
    }
}
