hasOne('App\Merchant','id','merchant_id'); } public function application() { return $this->hasOne('App\ConsumerApplication','user_id','id')->orderBy('created_at','desc'); } public function tokens(){ $token = $this->hasMany('App\GCMRegistraion','user_id','id')->whereIn('status',['Active', 'active']); if(static::$device_id){ $token->where('device_id', static::$device_id); } return $token; } public function referrals(){ return $this->hasMany('App\Merchant','referred_by','code'); } public function calls(){ return $this->hasMany('App\CallLogs','_id','id')->where('id_type','user_id')->where(function ($query) { $query->whereNull('status') ->orWhereIn('status', ['in-progress','ringing']); }); } public function user_types(){ return $this->hasOne('App\UserTypes','id','user_type'); } /** * Whether this user is authorised to approve a settlement request with the * given waiver percentage. A user can approve any waiver up to (and * including) their configured Maximum POS Waiver. */ public function canApproveSettlementWaiver($waiverPercentage) { return (float) $this->max_pos_waiver > 0 && (float) $this->max_pos_waiver >= (float) $waiverPercentage; } }