<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

use Illuminate\Foundation\Auth\User as Authenticatable;

class ReferalCode extends Model
{
     use Notifiable;

 # define table
  protected $table ='referral_codes';
  
  # define fillable fields
  protected $fillable = [
  	                   'user_id',
  	                   'code',
  	                   'earnings',
                       
  ];

     /**
   * The attributes that should be cast.
   *
   * @var array
   */
  protected $casts = [
      'status'  => 'boolean',
  ];
  
    public function user()
    {
       
        return $this->hasOne(new Users(), 'id', 'user_id');
    }
    public function refelCodeHis()
    {
       
        return $this->hasMany(new ReferalCodeHistory(), 'referal_codes_id', 'id');
    }
}
