<?php

namespace App\Models;

use App\Traits\Blameable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Pesanan extends Model
{
    use HasFactory, Blameable, SoftDeletes;

    protected $table = 'pesanans';

    protected $fillable = [
        'kode_pesanan',
        'nama_pemesan',
        'status_pesanan',
        'tanggal_pesanan',
        'nomor_meja',
        'keterangan_pesanan',
        'total_pesanan',
        'total_bayar',
        'grand_total',
        'nominal_bayar',
        'nominal_kembali',
        'diskon_id',
        'nama_diskon',
        'kode_diskon',
        'diskon_persen',
        'diskon_rupiah',
        'user_id',
    ];

    public function detailPesanan()
    {
        return $this->hasMany(DetailPesanan::class, 'pesanan_id');
    }

    public function diskon()
    {
        return $this->belongsTo(Diskon::class, 'diskon_id');
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }
}
