<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Spatie\Permission\Traits\HasRoles;
use Illuminate\Database\Eloquent\SoftDeletes;
use Laravel\Passport\HasApiTokens;

class Users extends Authenticatable
{
    use Notifiable, HasRoles, HasApiTokens, SoftDeletes;

    # define table
    protected $table = 'users';

    # define fillable fields
    protected $fillable = [
        'name',
        'email',
        'password',
        'mobile_number',
        'state_id',
        'rate_type',
        'status',
        'c_time',
        'gpay',
        'ppay',
        'device_key',
        'app_version',
        'referal_code',
        'commission',
        'one_into_three_own_referral_no',
        'one_into_three_invitation_referral_no',
        'type'

    ];

    /**
     * The attributes that should be cast.
     *
     * @var array
     */
    protected $casts = [
        'status'  => 'boolean',
    ];


    public function referalCode()
    {

        return $this->hasOne(new ReferalCode(), 'user_id', 'id');
    }

    public function userBank()
    {

        return $this->hasOne(new UserBanks(), 'user_id', 'id');
    }

    public function headUser()
    {
        return $this->hasOne('App\Models\UserRefer', 'user_id', 'id');
    }

    public function paymentHistory()
    {

        return $this->hasOne('App\Models\PaymentHistory', 'user_id', 'id');
    }
    
       public function bit()
    {
       
        return $this->hasOne('App\Models\Bit', 'user_id', 'id');
    }
    

    public function userActive()
    {

        return $this->hasOne(new UserActives(), 'user_id', 'id');
    }
}