'array', ]; public function sf_guard_user() { return $this->hasOne(SfGuardUser::class, 'user_id', 'id'); } public function account() { return $this->hasOne('App\Models\Account'); } /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function user_update_email() { return $this->hasMany('App\Models\UserUpdateEmail', 'user_id', 'id'); } public function isGoogle2Fa(){ return ($this->google2fa && $this->secret_key) ? true : false; } public function setSecretKeyAttribute($value) { $this->attributes['secret_key'] = $value ? Crypt::encryptString($value) : null; } public function getSecretKeyAttribute($value) { return $value ? Crypt::decryptString($value) : null; } /** * @return bool */ public function isPasswort(){ if($this->password == env('APP_KEY')){ return false; } return true; } /** * @return bool */ public function isAdmin() { if(!$this->active){ return false; } if($this->admin >= 1){ return true; } return false; } /** * @return bool */ public function isSuperAdmin() { if(!$this->active){ return false; } if($this->admin >= 2){ return true; } return false; } /** * @return bool */ public function isSySAdmin() { if(!$this->active){ return false; } if($this->admin >= 3){ return true; } return false; } private function setPermissionsDefault(){ $groups = config('permissions.groups'); $permissions = []; foreach ($groups as $role_id => $perms){ if($role_id <= $this->admin){ foreach ($perms as $key => $val){ $permissions[$key] = 1; } } } $this->permissions = $permissions; } public function isPermission($key){ //default by role if(!is_array($this->permissions)){ $this->setPermissionsDefault(); } if($key == strtolower($key)){ if(isset($this->permissions[$key]) && $this->permissions[$key] == 1){ return true; } } return false; } /** * @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()); } /** * @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 "en"; } /** * 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)); } }