Undangan/backend-baru/app/Models/Pelanggan.php
2025-10-24 17:05:32 +07:00

53 lines
946 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Pelanggan extends Model
{
use HasFactory;
protected $table = 'pelanggans';
protected $fillable = [
'nama_pemesan',
'email',
'no_tlpn',
'template_id',
'form',
'harga',
'status',
'kode_pelanggan',
];
protected $casts = [
'form' => 'array',
'harga' => 'decimal:2',
];
public function template()
{
return $this->belongsTo(Template::class, 'template_id');
}
public function guests()
{
return $this->hasMany(Guest::class, 'id_pelanggan');
}
public function rsvp()
{
return $this->hasManyThrough(
Rsvp::class,
Guest::class,
'id_pelanggan',
'guest_id',
'id',
'id'
);
}
}