<?php

namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasRoles;
    /** @use HasFactory<\Database\Factories\UserFactory> */
    use HasFactory, Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var list<string>
     */
    protected $fillable = [

        'user_id',
        'payment_method',
        'network',
        'register_from',
        'wallet',
        'pwd',
        'pwd_hint',
        'teams',
        'level',
        'investment',
        'repurchase',
        'pv',
        'name',
        'left_pv',
        'right_pv',
        'team',
        'level_tree',
        'ref_id',
        'entry_date',
        'status',
        'user_type',
        'rank',
        'phone',
        'email',
        'dob',
        'gender',
        'f_name',
        'l_name',
        'prefered_position',
        'title',
        'door',
        'street',
        'city',
        'district',
        'state',
        'country',
        'pin',
        'pimage',
        'address1',
        'address2',
        'pincode',
        'n_address',
        'n_relation',
        'n_phone',
        'n_name',
        'active_by',
    ];

    public function diamondRoiUsers()
    {
        return $this->hasMany(DiamondRoiUser::class, 'user_id', 'user_id');
    }

    public function silverRoiUsers()
    {
        return $this->hasMany(SilverRoiUser::class, 'user_id', 'user_id');
    }


    /**
     * The attributes that should be hidden for serialization.
     *
     * @var list<string>
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

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