<?php

namespace App\Models;

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

class CustomerAppointment extends Model
{
    public const STATUSES = ['scheduled', 'completed', 'cancelled'];

    protected $fillable = [
        'branch_id','customer_id','staff_id','title','purpose','scheduled_at','status','notes','created_by','updated_by',
    ];

    protected function casts(): array
    {
        return ['scheduled_at'=>'datetime'];
    }

    public function branch(): BelongsTo { return $this->belongsTo(Branch::class); }
    public function customer(): BelongsTo { return $this->belongsTo(Customer::class); }
    public function staff(): BelongsTo { return $this->belongsTo(User::class, 'staff_id'); }
    public function creator(): BelongsTo { return $this->belongsTo(User::class, 'created_by'); }
    public function updater(): BelongsTo { return $this->belongsTo(User::class, 'updated_by'); }
}