<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

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

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'email', 'first_name', 'last_name', 'referral_code', 'street_address', 'street_address2', 'country', 'state',
        'city', 'zip', 'phone', 'password', 'wallet_balance', 'profit'
    ];

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

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    /**
     * User Country
     *
     * @return BelongsTo
     */
    public function countryName(): BelongsTo
    {
        return $this->belongsTo(Country::class, 'country');
    }

    /**
     * User State
     *
     * @return BelongsTo
     */
    public function stateName(): BelongsTo
    {
        return $this->belongsTo(State::class, 'state');
    }

    /**
     * User City
     *
     * @return BelongsTo
     */
    public function cityName(): BelongsTo
    {
        return $this->belongsTo(City::class, 'city');
    }
}
