10.April 2026
This commit is contained in:
parent
a00c42e770
commit
f58c709945
208 changed files with 19280 additions and 2914 deletions
162
app/User.php
162
app/User.php
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
namespace App;
|
||||
|
||||
use App\Models\PaymentMethod;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Mail\MailResetPassword;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\UserSalesVolume;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Laravel\Passport\HasApiTokens;
|
||||
|
||||
/**
|
||||
|
|
@ -24,6 +24,7 @@ use Laravel\Passport\HasApiTokens;
|
|||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereId($value)
|
||||
|
|
@ -32,6 +33,7 @@ use Laravel\Passport\HasApiTokens;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereRememberToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereUpdatedAt($value)
|
||||
*
|
||||
* @property int $confirmed
|
||||
* @property string|null $confirmation_code
|
||||
* @property string|null $confirmation_date
|
||||
|
|
@ -47,6 +49,7 @@ use Laravel\Passport\HasApiTokens;
|
|||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property-read \App\Models\Account $account
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserUpdateEmail[] $user_update_email
|
||||
*
|
||||
* @method static bool|null forceDelete()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\User onlyTrashed()
|
||||
* @method static bool|null restore()
|
||||
|
|
@ -65,11 +68,14 @@ use Laravel\Passport\HasApiTokens;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereNotes($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\User withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\User withoutTrashed()
|
||||
*
|
||||
* @property int|null $account_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereAccountId($value)
|
||||
*
|
||||
* @property int|null $wizard
|
||||
* @property int|null $blocked
|
||||
* @property string|null $payment_account
|
||||
|
|
@ -77,16 +83,20 @@ use Laravel\Passport\HasApiTokens;
|
|||
* @property-read int|null $notifications_count
|
||||
* @property-read \App\Models\UserShop $shop
|
||||
* @property-read int|null $user_update_email_count
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereBlocked($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User wherePaymentAccount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User wherePaymentShop($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereWizard($value)
|
||||
*
|
||||
* @property int|null $m_level
|
||||
* @property int|null $m_sponsor
|
||||
* @property-read \App\Models\UserLevel|null $user_level
|
||||
* @property-read \App\User|null $user_sponsor
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereMLevel($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereMSponsor($value)
|
||||
*
|
||||
* @property string|null $release_account
|
||||
* @property int|null $payment_order_id
|
||||
* @property int|null $abo_options
|
||||
|
|
@ -95,9 +105,11 @@ use Laravel\Passport\HasApiTokens;
|
|||
* @property-read \App\Models\Product|null $payment_order
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrder[] $shopping_orders
|
||||
* @property-read int|null $shopping_orders_count
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereAboOptions($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User wherePaymentOrderId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereReleaseAccount($value)
|
||||
*
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\UserHistory[] $user_histories
|
||||
* @property-read int|null $user_histories_count
|
||||
* @property int|null $test_mode
|
||||
|
|
@ -107,28 +119,37 @@ use Laravel\Passport\HasApiTokens;
|
|||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingUser[] $member_shopping_users
|
||||
* @property-read int|null $member_shopping_users_count
|
||||
* @property-read \App\Models\Product|null $payment_order_product
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereSettings($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereTestMode($value)
|
||||
*
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Laravel\Passport\Client[] $clients
|
||||
* @property-read int|null $clients_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Laravel\Passport\Token[] $tokens
|
||||
* @property-read int|null $tokens_count
|
||||
* @property array|null $payment_methods
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User wherePaymentMethods($value)
|
||||
*
|
||||
* @property int|null $pre_sponsor
|
||||
* @property-read User|null $user_pre_sponsor
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|User wherePreSponsor($value)
|
||||
*
|
||||
* @property \Illuminate\Support\Carbon|null $pre_deleted_at
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder<static>|User wherePreDeletedAt($value)
|
||||
*
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\UserBusiness> $userBusiness
|
||||
* @property-read int|null $user_business_count
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use Notifiable, HasApiTokens;
|
||||
|
||||
use HasApiTokens, Notifiable;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
protected $table = 'users';
|
||||
|
|
@ -138,7 +159,6 @@ class User extends Authenticatable
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
|
||||
protected $fillable = [
|
||||
'email',
|
||||
'password',
|
||||
|
|
@ -195,7 +215,6 @@ class User extends Authenticatable
|
|||
return $this->hasMany('App\Models\File', 'user_id', '');
|
||||
}
|
||||
|
||||
|
||||
public function shopping_orders()
|
||||
{
|
||||
return $this->hasMany('App\Models\ShoppingOrder', 'auth_user_id', '');
|
||||
|
|
@ -236,24 +255,26 @@ class User extends Authenticatable
|
|||
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;
|
||||
return $this->user_sponsor->account->first_name.' '.$this->user_sponsor->account->last_name.' | '.$this->user_sponsor->email;
|
||||
}
|
||||
}
|
||||
|
||||
public function getFullName($email = true)
|
||||
{
|
||||
$ret = "";
|
||||
$ret = '';
|
||||
if ($this->account) {
|
||||
$ret = $this->account->first_name . " " . $this->account->last_name;
|
||||
$ret = $this->account->first_name.' '.$this->account->last_name;
|
||||
}
|
||||
if ($email && $this->id > 1) {
|
||||
$ret .= " | " . $this->email;
|
||||
$ret .= ' | '.$this->email;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -262,10 +283,10 @@ class User extends Authenticatable
|
|||
if ($this->password == env('APP_KEY')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -274,10 +295,10 @@ class User extends Authenticatable
|
|||
if ($this->admin >= 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -286,6 +307,7 @@ class User extends Authenticatable
|
|||
if ($this->admin >= 2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -297,6 +319,7 @@ class User extends Authenticatable
|
|||
if ($this->admin >= 3) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -308,15 +331,16 @@ class User extends Authenticatable
|
|||
if ($this->admin >= 4) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function isUserHasApi()
|
||||
{
|
||||
if ($this->id === 3) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -328,6 +352,7 @@ class User extends Authenticatable
|
|||
if ($this->admin >= 5) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -339,15 +364,25 @@ class User extends Authenticatable
|
|||
return $this->test_mode ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function showSideNav()
|
||||
{
|
||||
if ($this->active == 1 && $this->blocked == 0 && $this->wizard >= 10) {
|
||||
if ($this->blocked != 0 || $this->wizard < 10) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->active == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Nach Account-Ablauf setzt u. a. cleanUpInActiveUser active=0; Zahlung/Mitgliedschaft
|
||||
// muss im CRM weiterhin erreichbar sein (Navigation „Mein Konto“).
|
||||
if ($this->payment_account && ! $this->isActiveAccount()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -361,6 +396,7 @@ class User extends Authenticatable
|
|||
{
|
||||
return ($this->active == 1 && $this->blocked == 0) ? true : false;
|
||||
}
|
||||
|
||||
public function isActiveAccount()
|
||||
{
|
||||
return $this->payment_account ? Carbon::parse($this->payment_account)->gt(Carbon::now()) : false;
|
||||
|
|
@ -374,14 +410,15 @@ class User extends Authenticatable
|
|||
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;
|
||||
return $this->payment_account ? Carbon::parse($this->payment_account)->modify('-'.config('mivita.renewal_days').' days')->format(\Util::formatDateTimeDB()) : false;
|
||||
}
|
||||
|
||||
public function daysActiveAccount()
|
||||
|
|
@ -389,7 +426,7 @@ class User extends Authenticatable
|
|||
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());
|
||||
}
|
||||
|
|
@ -404,7 +441,7 @@ class User extends Authenticatable
|
|||
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());
|
||||
}
|
||||
|
|
@ -417,12 +454,13 @@ class User extends Authenticatable
|
|||
public function isAcountAboPayDate()
|
||||
{
|
||||
if ($this->isAboOption()) {
|
||||
$pay_days = Carbon::parse($this->payment_account)->modify('- ' . config('mivita.abo_booking_days') . ' days');
|
||||
$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) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -431,9 +469,10 @@ class User extends Authenticatable
|
|||
*/
|
||||
public function getConfirmationDateFormat()
|
||||
{
|
||||
if (!$this->attributes['confirmation_date']) {
|
||||
return "";
|
||||
if (! $this->attributes['confirmation_date']) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return Carbon::parse($this->attributes['confirmation_date'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
|
|
@ -442,12 +481,13 @@ class User extends Authenticatable
|
|||
*/
|
||||
public function getActiveDateFormat($time = true)
|
||||
{
|
||||
if (!$this->attributes['active_date']) {
|
||||
return "";
|
||||
if (! $this->attributes['active_date']) {
|
||||
return '';
|
||||
}
|
||||
if (!$time) {
|
||||
if (! $time) {
|
||||
return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateDB());
|
||||
}
|
||||
|
||||
return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
|
|
@ -456,55 +496,59 @@ class User extends Authenticatable
|
|||
*/
|
||||
public function getAgreementFormat()
|
||||
{
|
||||
if (!$this->attributes['agreement']) {
|
||||
return "";
|
||||
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 (! $this->attributes['payment_account']) {
|
||||
return '';
|
||||
}
|
||||
if (!$time) {
|
||||
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 (! $this->attributes['payment_shop']) {
|
||||
return '';
|
||||
}
|
||||
if (!$time) {
|
||||
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 (! $this->attributes['release_account']) {
|
||||
return '';
|
||||
}
|
||||
if (!$time) {
|
||||
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) {
|
||||
if (! $this->settings) {
|
||||
$this->settings = [];
|
||||
}
|
||||
$this->settings = array_merge($this->settings, $revisions);
|
||||
if ($save) {
|
||||
$this->save();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -515,38 +559,41 @@ class User extends Authenticatable
|
|||
|
||||
public function getPaymentMethodsShort()
|
||||
{
|
||||
$ret = "";
|
||||
$ret = '';
|
||||
if ($this->payment_methods !== null) {
|
||||
foreach ($this->payment_methods as $payment_method) {
|
||||
if ($find = PaymentMethod::find($payment_method)) {
|
||||
$ret .= $find->short . " | ";
|
||||
$ret .= $find->short.' | ';
|
||||
}
|
||||
}
|
||||
$ret = rtrim($ret, " | ");
|
||||
$ret = rtrim($ret, ' | ');
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLandByCountry()
|
||||
{
|
||||
if ($this->account && $this->account->country_id) {
|
||||
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';
|
||||
}
|
||||
}
|
||||
return "de";
|
||||
|
||||
return 'de';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -557,16 +604,16 @@ class User extends Authenticatable
|
|||
*/
|
||||
public function sendPasswordResetNotification($token)
|
||||
{
|
||||
//$bcc[] = "kevin.adametz@me.com"; //config('app.checkout_mail');
|
||||
//Mail::to($this->email)->bcc($bcc)->locale(\App::getLocale())->send(new MailResetPassword($token, $this));
|
||||
// $bcc[] = "kevin.adametz@me.com"; //config('app.checkout_mail');
|
||||
// Mail::to($this->email)->bcc($bcc)->locale(\App::getLocale())->send(new MailResetPassword($token, $this));
|
||||
Mail::to($this->email)->locale(\App::getLocale())->send(new MailResetPassword($token, $this));
|
||||
//$this->notify(new ResetPasswordNotification($token));
|
||||
// $this->notify(new ResetPasswordNotification($token));
|
||||
}
|
||||
|
||||
public function getUserSalesVolumeBy($month, $year, $key)
|
||||
{
|
||||
|
||||
//NOTE check ist, cant change month year !
|
||||
// NOTE check ist, cant change month year !
|
||||
if ($this->userSalesVolume === false) {
|
||||
$this->userSalesVolume = $this->getUserSalesVolume($month, $year, 'first');
|
||||
}
|
||||
|
|
@ -588,7 +635,7 @@ class User extends Authenticatable
|
|||
case 'sales_volume_points_TP_sum':
|
||||
return $this->userSalesVolume->getPointsTPSum();
|
||||
break;
|
||||
//price net
|
||||
// price net
|
||||
case 'sales_volume_total':
|
||||
return $this->userSalesVolume->month_total_net;
|
||||
break;
|
||||
|
|
@ -602,10 +649,11 @@ class User extends Authenticatable
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//with = ['shopping_order.shopping_user'] <- optional wenn es noch weitere relations gibt
|
||||
// with = ['shopping_order.shopping_user'] <- optional wenn es noch weitere relations gibt
|
||||
public function getUserSalesVolume($month, $year, $record = 'get', $with = [])
|
||||
{
|
||||
$relations = array_merge(['shopping_order'], $with);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue