belongsTo('App\Models\UserAccount', 'account_id'); } public function user_level(){ return $this->belongsTo('App\Models\UserLevel', 'm_level'); } public function user_sponsor(){ return $this->belongsTo('App\User', 'm_sponsor'); } public function payment_order_product(){ return $this->belongsTo('App\Models\Product', 'payment_order_id'); } public function files(){ return $this->hasMany('App\Models\File', 'user_id', ''); } public function shopping_orders(){ return $this->hasMany('App\Models\ShoppingOrder', 'auth_user_id', ''); } public function user_histories(){ return $this->hasMany('App\Models\UserHistory', 'user_id', ''); } public function shop() { return $this->hasOne('App\Models\UserShop', 'user_id', 'id'); } public function user_update_email() { return $this->hasMany('App\Models\UserUpdateEmail', 'user_id', 'id'); } public function getMUserSponsor(){ if($this->user_sponsor && $this->user_sponsor->account){ return $this->user_sponsor->account->first_name." ".$this->user_sponsor->account->last_name." | ".$this->user_sponsor->email; } } /** * @return bool */ public function isPasswort(){ if($this->password == env('APP_KEY')){ return false; } return true; } /** * @return bool */ public function isAdmin() { if($this->admin >= 1){ return true; } return false; } /** * @return bool */ public function isSuperAdmin() { if($this->admin >= 2){ return true; } return false; } /** * @return bool */ public function isSySAdmin() { if($this->admin >= 3){ return true; } return false; } /** * @return bool */ public function isTestMode() { return $this->test_mode ? true : false; } /** * @return bool */ public function showSideNav() { if($this->active == 1 && $this->blocked == 0 && $this->wizard >= 10){ return true; } return false; } public function isAboOption(){ return ($this->abo_options && $this->account && $this->account->payment_data) ? true : false; } public function isActiveAccount(){ return $this->payment_account ? Carbon::parse($this->payment_account)->gt(Carbon::now()) : false; } public function isActiveShop(){ return $this->payment_shop ? Carbon::parse($this->payment_shop)->gt(Carbon::now()) : false; } public function isRenewalAccount() { if ($this->payment_account) { return Carbon::parse($this->payment_account)->modify('-'.(config('mivita.renewal_days')+1).' days')->lt(Carbon::now()); } return false; } public function nextRenewalAccount(){ return $this->payment_account ? Carbon::parse($this->payment_account)->modify('-'.config('mivita.renewal_days').' days')->format(\Util::formatDateTimeDB()) : false ; } public function daysActiveAccount(){ return Carbon::now()->diffInDays(Carbon::parse($this->payment_account), false); } public function modifyActiveAccount($add = "1 year"){ return Carbon::parse($this->payment_account)->modify($add)->format(\Util::formatDateTimeDB()); } public function daysHumansActiveAccount(){ return Carbon::now()->diffForHumans(Carbon::parse($this->payment_account)); } public function daysActiveShop(){ return Carbon::now()->diffInDays(Carbon::parse($this->payment_shop), false); } public function modifyActiveShop($add = "1 year"){ return Carbon::parse($this->payment_shop)->modify($add)->format(\Util::formatDateTimeDB()); } public function daysHumansActiveShop(){ return Carbon::now()->diffForHumans(Carbon::parse($this->payment_shop)); } /** * @return string */ public function getConfirmationDateFormat(){ if(!$this->attributes['confirmation_date']){ return ""; } return Carbon::parse($this->attributes['confirmation_date'])->format(\Util::formatDateTimeDB()); } /** * @return string */ public function getActiveDateFormat(){ if(!$this->attributes['active_date']){ return ""; } return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateTimeDB()); } /** * @return string */ public function getAgreementFormat(){ if(!$this->attributes['agreement']){ return ""; } return Carbon::parse($this->attributes['agreement'])->format(\Util::formatDateTimeDB()); } public function getPaymentAccountDateFormat($time = true){ if(!$this->attributes['payment_account']){ return ""; } if(!$time){ return Carbon::parse($this->attributes['payment_account'])->format(\Util::formatDateDB()); } return Carbon::parse($this->attributes['payment_account'])->format(\Util::formatDateTimeDB()); } public function getPaymentShopDateFormat($time = true){ if(!$this->attributes['payment_shop']){ return ""; } if(!$time){ return Carbon::parse($this->attributes['payment_shop'])->format(\Util::formatDateDB()); } return Carbon::parse($this->attributes['payment_shop'])->format(\Util::formatDateTimeDB()); } public function getReleaseAccountFormat($time = true){ if(!$this->attributes['release_account']){ return ""; } if(!$time){ return Carbon::parse($this->attributes['release_account'])->format(\Util::formatDateDB()); } return Carbon::parse($this->attributes['release_account'])->format(\Util::formatDateTimeDB()); } /** * @return string */ public function getLandByCountry(){ if($this->account && $this->account->country_id){ $code = $this->account->country->code; if($code == "FR"){ return 'fr'; } if($code == "CH"){ return 'de'; } if($code == "NL"){ return 'nl'; } if($code == "DE"){ return 'de'; } } return "de"; } /** * Send the password reset notification. * * @param string $token * @return void */ public function sendPasswordResetNotification($token) { Mail::to($this->email)->send(new MailResetPassword($token, $this)); // $this->notify(new ResetPasswordNotification($token)); } }