Updates to 03-2025
This commit is contained in:
parent
bfa3bb1df4
commit
9ae662f63e
243 changed files with 12580 additions and 12018 deletions
|
|
@ -8,20 +8,20 @@ namespace App\Models;
|
|||
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use App\Services\Util;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class UserAbo
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int $payone_userid
|
||||
* @property string $clearingtype
|
||||
* @property string|null $wallettype
|
||||
* @property int $amount
|
||||
* @property string $currency
|
||||
* @property bool $active
|
||||
* @property int $status
|
||||
* @property int $abo_interval
|
||||
|
|
@ -32,11 +32,51 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property Carbon|null $user_deleted_at
|
||||
*
|
||||
* @property User $user
|
||||
* @property Collection|UserAboOrder[] $user_abo_orders
|
||||
*
|
||||
* @package App\Models
|
||||
* @property int|null $member_id
|
||||
* @property int $shopping_user_id
|
||||
* @property string|null $email
|
||||
* @property string|null $is_for
|
||||
* @property array|null $carddata
|
||||
* @property \Illuminate\Support\Carbon|null $start_date
|
||||
* @property \Illuminate\Support\Carbon|null $last_date
|
||||
* @property \Illuminate\Support\Carbon|null $next_date
|
||||
* @property-read User|null $member
|
||||
* @property-read \App\Models\ShoppingUser $shopping_user
|
||||
* @property-read Collection<int, \App\Models\UserAboItem> $user_abo_items
|
||||
* @property-read int|null $user_abo_items_count
|
||||
* @property-read int|null $user_abo_orders_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereAboInterval($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereAmount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereCancelDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereCarddata($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereClearingtype($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereIsFor($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereLastDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereMemberId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereNextDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo wherePayoneUserid($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereShoppingUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereStartDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereUserDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereWallettype($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo withTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserAbo extends Model
|
||||
{
|
||||
|
|
@ -45,29 +85,33 @@ class UserAbo extends Model
|
|||
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'member_id' => 'int',
|
||||
'shopping_user_id' => 'int',
|
||||
'payone_userid' => 'int',
|
||||
'amount' => 'int',
|
||||
'active' => 'bool',
|
||||
'status' => 'int',
|
||||
'abo_interval' => 'int',
|
||||
'amount' => 'int',
|
||||
'start_date' => 'datetime',
|
||||
'last_date' => 'datetime',
|
||||
'next_date' => 'datetime',
|
||||
'cancel_date' => 'datetime',
|
||||
'count' => 'int',
|
||||
'user_deleted_at' => 'datetime'
|
||||
'user_deleted_at' => 'datetime',
|
||||
'carddata' => 'array'
|
||||
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'member_id',
|
||||
'shopping_user_id',
|
||||
'is_for',
|
||||
'email',
|
||||
'payone_userid',
|
||||
'clearingtype',
|
||||
'wallettype',
|
||||
'carddata',
|
||||
'amount',
|
||||
'currency',
|
||||
'active',
|
||||
'status',
|
||||
'abo_interval',
|
||||
|
|
@ -75,13 +119,43 @@ class UserAbo extends Model
|
|||
'last_date',
|
||||
'next_date',
|
||||
'cancel_date',
|
||||
'count',
|
||||
'user_deleted_at'
|
||||
];
|
||||
|
||||
public static $aboDeliveryDays = [5, 10, 20, 25];
|
||||
|
||||
public static $statusTypes = [
|
||||
0 => 'abo_new',
|
||||
1 => 'abo_new',
|
||||
2 => 'abo_okay',
|
||||
3 => 'abo_hold',
|
||||
4 => 'abo_cancel',
|
||||
5 => 'abo_finish',
|
||||
6 => 'abo_inactive',
|
||||
7 => 'abo_grace'
|
||||
];
|
||||
|
||||
public static $statusColors = [
|
||||
0 => 'success',
|
||||
1 => 'success',
|
||||
2 => 'secondary',
|
||||
3 => 'warning',
|
||||
4 => 'danger',
|
||||
5 => 'info',
|
||||
6 => 'warning',
|
||||
7 => 'danger'
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function member()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'member_id');
|
||||
}
|
||||
|
||||
public function shopping_user()
|
||||
|
|
@ -89,12 +163,21 @@ class UserAbo extends Model
|
|||
return $this->belongsTo('App\Models\ShoppingUser','shopping_user_id');
|
||||
}
|
||||
|
||||
|
||||
public function user_abo_orders()
|
||||
{
|
||||
return $this->hasMany(UserAboOrder::class);
|
||||
}
|
||||
|
||||
public function user_abo_items()
|
||||
{
|
||||
return $this->hasMany(UserAboItem::class);
|
||||
}
|
||||
|
||||
public function getCountOrders(){
|
||||
//sind bezahlte Bestellungen
|
||||
return $this->user_abo_orders->where('status', '>=', 2)->count();
|
||||
}
|
||||
|
||||
public function setStartDateAttribute( $value ) {
|
||||
$this->attributes['start_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
|
|
@ -127,5 +210,29 @@ class UserAbo extends Model
|
|||
return $this->attributes['cancel_date'] ? Carbon::parse($this->attributes['cancel_date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
|
||||
public function getFormattedAmount()
|
||||
{
|
||||
return isset($this->attributes['amount']) ? Util::formatNumber($this->attributes['amount']/100) : "";
|
||||
}
|
||||
public function getIsForFormated()
|
||||
{
|
||||
return $this->attributes['is_for'] === 'me' ? '<span class="badge badge-outline-warning-dark">'.__('tables.adviser').'</span>' : '<span class="badge badge-outline-info">'.__('tables.customer').'</span>';
|
||||
}
|
||||
|
||||
public function getStatusFormated(){
|
||||
return '<span class="badge badge-pill badge-'.$this->getStatusColor().'">'.$this->getStatusType().'</span>';
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? __('abo.'.self::$statusTypes[$this->status]) : "";
|
||||
}
|
||||
|
||||
public function getStatusColor(){
|
||||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
|
||||
}
|
||||
|
||||
public function getPaymentType(){
|
||||
return $this->clearingtype === 'wlt' ? __('payment.paypal') : __('payment.credit_card');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue