<?php

namespace App\Models;

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

class User extends Authenticatable
{
    use HasFactory, Notifiable;

    /**
     * The attributes that are mass assignable.
     */
    protected $fillable = [
        'name',
        'email',
        'password',
        'phone',
        'detail_address',
        'province_id',     // BinderByte
        'province_name',   // BinderByte
        'city_id',         // BinderByte
        'city_name',       // BinderByte
        'district_id',     // <--- TAMBAHKAN INI (Kecamatan)
        'district_name',   // <--- TAMBAHKAN INI (Kecamatan)
        'village_id',      // <--- TAMBAHKAN INI (Desa/Kelurahan)
        'village_name',    // <--- TAMBAHKAN INI (Desa/Kelurahan)
        'is_admin',
        'photo',           // FOTO PROFIL
    ];

    /**
     * The attributes that should be hidden for serialization.
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * Get the attributes that should be cast.
     */
    protected function casts(): array
    {
        return [
            'email_verified_at' => 'datetime',
            'password' => 'hashed',
            'is_admin' => 'boolean',
        ];
    }

    public function reviews()
    {
        return $this->hasMany(ProductReview::class);
    }
}
