Updates to 03-2025

This commit is contained in:
Kevin Adametz 2025-04-01 10:36:47 +02:00
parent bfa3bb1df4
commit 9ae662f63e
243 changed files with 12580 additions and 12018 deletions

View file

@ -136,12 +136,15 @@ class User extends Authenticatable
*/
protected $fillable = [
'email', 'password', 'token',
'email',
'password',
'token',
];
protected $casts = [
'settings' => 'array',
'payment_methods' => 'array'
'payment_methods' => 'array',
];
/**
@ -150,41 +153,51 @@ class User extends Authenticatable
* @var array
*/
protected $hidden = [
'password', 'remember_token', 'token',
'password',
'remember_token',
'token',
];
private $userSalesVolume = false;
public function account(){
public function account()
{
return $this->belongsTo('App\Models\UserAccount', 'account_id');
}
public function user_level(){
public function user_level()
{
return $this->belongsTo('App\Models\UserLevel', 'm_level');
}
public function user_sponsor(){
public function user_sponsor()
{
return $this->belongsTo('App\User', 'm_sponsor');
}
public function user_pre_sponsor(){
public function user_pre_sponsor()
{
return $this->belongsTo('App\User', 'pre_sponsor');
}
public function payment_order_product(){
public function payment_order_product()
{
return $this->belongsTo('App\Models\Product', 'payment_order_id');
}
public function files(){
public function files()
{
return $this->hasMany('App\Models\File', 'user_id', '');
}
public function shopping_orders(){
public function shopping_orders()
{
return $this->hasMany('App\Models\ShoppingOrder', 'auth_user_id', '');
}
public function user_histories(){
public function user_histories()
{
return $this->hasMany('App\Models\UserHistory', 'user_id', '');
}
@ -208,33 +221,35 @@ class User extends Authenticatable
return $this->hasMany('App\Models\ShoppingUser', 'member_id', 'id');
}
public function getLocale(){
public function getLocale()
{
return $this->lang ? $this->lang : \App::getLocale();
}
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;
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;
}
}
public function getFullName($email=true){
public function getFullName($email = true)
{
$ret = "";
if($this->account){
$ret = $this->account->first_name." ".$this->account->last_name;
if ($this->account) {
$ret = $this->account->first_name . " " . $this->account->last_name;
}
if($email && $this->id > 1){
$ret .= " | ".$this->email;
if ($email && $this->id > 1) {
$ret .= " | " . $this->email;
}
return $ret;
}
/**
* @return bool
*/
public function isPasswort(){
if($this->password == env('APP_KEY')){
public function isPasswort()
{
if ($this->password == env('APP_KEY')) {
return false;
}
return true;
@ -246,7 +261,7 @@ class User extends Authenticatable
*/
public function isVIP()
{
if($this->admin >= 1){
if ($this->admin >= 1) {
return true;
}
return false;
@ -258,7 +273,7 @@ class User extends Authenticatable
*/
public function isAdmin()
{
if($this->admin >= 2){
if ($this->admin >= 2) {
return true;
}
return false;
@ -269,7 +284,7 @@ class User extends Authenticatable
*/
public function isSuperAdmin()
{
if($this->admin >= 3){
if ($this->admin >= 3) {
return true;
}
return false;
@ -280,7 +295,7 @@ class User extends Authenticatable
*/
public function isSySAdmin()
{
if($this->admin >= 4){
if ($this->admin >= 4) {
return true;
}
return false;
@ -289,7 +304,7 @@ class User extends Authenticatable
public function isUserHasApi()
{
if($this->id === 3){
if ($this->id === 3) {
return true;
}
return false;
@ -300,7 +315,7 @@ class User extends Authenticatable
*/
public function isApiUser()
{
if($this->admin >= 5){
if ($this->admin >= 5) {
return true;
}
return false;
@ -320,68 +335,81 @@ class User extends Authenticatable
*/
public function showSideNav()
{
if($this->active == 1 && $this->blocked == 0 && $this->wizard >= 10){
if ($this->active == 1 && $this->blocked == 0 && $this->wizard >= 10) {
return true;
}
return false;
}
public function isAboOption(){
return false;
public function isAboOption()
{
return false;
// Abo Option deaktiviert ($this->abo_options && $this->account && $this->account->payment_data) ? true : false;
}
public function isActive(){
public function isActive()
{
return ($this->active == 1 && $this->blocked == 0) ? true : false;
}
public function isActiveAccount(){
public function isActiveAccount()
{
return $this->payment_account ? Carbon::parse($this->payment_account)->gt(Carbon::now()) : false;
}
public function isActiveShop(){
public function isActiveShop()
{
return $this->payment_shop ? Carbon::parse($this->payment_shop)->gt(Carbon::now()) : false;
}
public function isRenewalAccount(){
public function isRenewalAccount()
{
if ($this->payment_account) {
return Carbon::parse($this->payment_account)->modify('-'.(config('mivita.renewal_days')+1).' days')->lt(Carbon::now());
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 nextRenewalAccount()
{
return $this->payment_account ? Carbon::parse($this->payment_account)->modify('-' . config('mivita.renewal_days') . ' days')->format(\Util::formatDateTimeDB()) : false;
}
public function daysActiveAccount(){
public function daysActiveAccount()
{
return Carbon::now()->diffInDays(Carbon::parse($this->payment_account), false);
}
public function modifyActiveAccount($add = "1 year"){
public function modifyActiveAccount($add = "1 year")
{
return Carbon::parse($this->payment_account)->modify($add)->format(\Util::formatDateTimeDB());
}
public function daysHumansActiveAccount(){
public function daysHumansActiveAccount()
{
return Carbon::now()->diffForHumans(Carbon::parse($this->payment_account));
}
public function daysActiveShop(){
public function daysActiveShop()
{
return Carbon::now()->diffInDays(Carbon::parse($this->payment_shop), false);
}
public function modifyActiveShop($add = "1 year"){
public function modifyActiveShop($add = "1 year")
{
return Carbon::parse($this->payment_shop)->modify($add)->format(\Util::formatDateTimeDB());
}
public function daysHumansActiveShop(){
public function daysHumansActiveShop()
{
return Carbon::now()->diffForHumans(Carbon::parse($this->payment_shop));
}
public function isAcountAboPayDate(){
if($this->isAboOption()){
$pay_days = Carbon::parse($this->payment_account)->modify('- '.config('mivita.abo_booking_days').' days');
public function isAcountAboPayDate()
{
if ($this->isAboOption()) {
$pay_days = Carbon::parse($this->payment_account)->modify('- ' . config('mivita.abo_booking_days') . ' days');
$diff_days = Carbon::now()->diffInDays($pay_days, false);
if($diff_days <= 0){
if ($diff_days <= 0) {
return true;
}
}
@ -391,54 +419,76 @@ class User extends Authenticatable
/**
* @return string
*/
public function getConfirmationDateFormat(){
if(!$this->attributes['confirmation_date']){ return ""; }
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 ""; }
public function getActiveDateFormat($time = true)
{
if (!$this->attributes['active_date']) {
return "";
}
if (!$time) {
return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateDB());
}
return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateTimeDB());
}
/**
* @return string
*/
public function getAgreementFormat(){
if(!$this->attributes['agreement']){ return ""; }
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){
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){
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){
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());
}
public function setSetting(array $revisions, bool $save = true){
if(!$this->settings){
public function setSetting(array $revisions, bool $save = true)
{
if (!$this->settings) {
$this->settings = [];
}
$this->settings = array_merge($this->settings, $revisions);
@ -448,16 +498,18 @@ class User extends Authenticatable
return $this;
}
public function getSetting($key, $default = null){
public function getSetting($key, $default = null)
{
return isset($this->settings[$key]) ? $this->settings[$key] : $default;
}
public function getPaymentMethodsShort(){
public function getPaymentMethodsShort()
{
$ret = "";
if($this->payment_methods !== null){
foreach ($this->payment_methods as $payment_method){
if($find = PaymentMethod::find($payment_method)){
$ret .= $find->short." | ";
if ($this->payment_methods !== null) {
foreach ($this->payment_methods as $payment_method) {
if ($find = PaymentMethod::find($payment_method)) {
$ret .= $find->short . " | ";
}
}
$ret = rtrim($ret, " | ");
@ -467,19 +519,20 @@ class User extends Authenticatable
/**
* @return string
*/
public function getLandByCountry(){
if($this->account && $this->account->country_id){
public function getLandByCountry()
{
if ($this->account && $this->account->country_id) {
$code = $this->account->country->code;
if($code == "FR"){
if ($code == "FR") {
return 'fr';
}
if($code == "CH"){
if ($code == "CH") {
return 'de';
}
if($code == "NL"){
if ($code == "NL") {
return 'nl';
}
if($code == "DE"){
if ($code == "DE") {
return 'de';
}
}
@ -504,10 +557,10 @@ class User extends Authenticatable
{
//NOTE check ist, cant change month year !
if($this->userSalesVolume === false){
if ($this->userSalesVolume === false) {
$this->userSalesVolume = $this->getUserSalesVolume($month, $year, 'first');
}
if($this->userSalesVolume){
if ($this->userSalesVolume) {
switch ($key) {
case 'sales_volume_KP_points':
return $this->userSalesVolume->month_KP_points;
@ -529,7 +582,7 @@ class User extends Authenticatable
case 'sales_volume_total':
return $this->userSalesVolume->month_total_net;
break;
case 'sales_volume_total_shop':
return $this->userSalesVolume->month_shop_total_net;
break;
@ -540,7 +593,7 @@ class User extends Authenticatable
}
}
return 0;
}
}
public function getUserSalesVolume($month, $year, $record = 'get')
{