<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class GuestCustomer extends Model
{
    protected $table = 'guest_customers';

    protected $fillable = [
        'session_id',
        'name',
        'phone',
        'address',
    ];

    // ── Relationships ─────────────────────────────────────────────────────

    public function orders(): HasMany
    {
        return $this->hasMany(Order::class, 'guest_customer_id');
    }

    // ── Scopes ────────────────────────────────────────────────────────────

    public function scopeForSession($query, string $sessionId)
    {
        return $query->where('session_id', $sessionId);
    }
}
