<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;

    protected $fillable = ['name', 'email', 'password', 'phone','address' ,'role'];

    /**
     * Periksa apakah user adalah admin.
     */
    public function isAdmin()
    {
        return $this->role === 'admin';
    }

    /**
     * Periksa apakah user adalah pegawai.
     */
    public function isEmployee()
    {
        return $this->role === 'employee';
    }

    /**
     * Periksa apakah user adalah customer.
     */
    public function isCustomer()
    {
        return $this->role === 'customer';
    }

    /**
     * Relasi ke Booking.
     */
    public function bookings()
    {
        return $this->hasMany(Booking::class, 'customer_id');
    }

    /**
     * Relasi ke Photo.
     */
    public function photos()
    {
        return $this->hasMany(Photo::class, 'customer_id');
    }
}
