23-01-2026
This commit is contained in:
parent
a939cd51ef
commit
a8b395e20d
248 changed files with 29342 additions and 4805 deletions
|
|
@ -40,6 +40,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property-read int|null $shopping_orders_count
|
||||
* @property-read \App\Models\Country $billing_country
|
||||
* @property-read \App\Models\Country $shipping_country
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser query()
|
||||
|
|
@ -70,57 +71,80 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingSalutation($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingZipcode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereUpdatedAt($value)
|
||||
*
|
||||
* @property int|null $orders
|
||||
* @property-read \App\Models\ShoppingOrder $shopping_order
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrder[] $shopping_orders
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereOrders($value)
|
||||
*
|
||||
* @property int|null $abo_options
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereAboOptions($value)
|
||||
*
|
||||
* @property int|null $member_id
|
||||
* @property int|null $number
|
||||
* @property bool $is_like
|
||||
* @property array|null $notice
|
||||
* @property-read \App\User|null $auth_user
|
||||
* @property-read \App\User|null $member
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereIsLike($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereMemberId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereNotice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereNumber($value)
|
||||
*
|
||||
* @property bool|null $has_buyed
|
||||
* @property bool|null $subscribed
|
||||
* @property int|null $wp_order_number
|
||||
* @property string|null $wp_order_date
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereHasBuyed($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereSubscribed($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereWpOrderDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereWpOrderNumber($value)
|
||||
*
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property string|null $user_deleted_at
|
||||
*
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingUser onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereUserDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingUser withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\ShoppingUser withoutTrashed()
|
||||
*
|
||||
* @property string|null $mode
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereMode($value)
|
||||
*
|
||||
* @property bool|null $faker_mail
|
||||
* @property string|null $shipping_email
|
||||
* @property string|null $is_for
|
||||
* @property string|null $is_from
|
||||
* @property int|null $shopping_user_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereFakerMail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereIsFor($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereIsFrom($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShoppingUserId($value)
|
||||
*
|
||||
* @property int|null $homeparty_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUser whereHomepartyId($value)
|
||||
*
|
||||
* @property int|null $shopping_collect_order_id
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUser whereShoppingCollectOrderId($value)
|
||||
*
|
||||
* @property string|null $remarks
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUser whereRemarks($value)
|
||||
*
|
||||
* @property string|null $language
|
||||
*
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUser whereLanguage($value)
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShoppingUser extends Model
|
||||
|
|
@ -128,10 +152,9 @@ class ShoppingUser extends Model
|
|||
protected $table = 'shopping_users';
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'auth_user_id',
|
||||
'member_id',
|
||||
|
|
@ -163,6 +186,7 @@ class ShoppingUser extends Model
|
|||
'shipping_city',
|
||||
'shipping_country_id',
|
||||
'shipping_phone',
|
||||
'shipping_postnumber',
|
||||
'has_buyed',
|
||||
'subscribed',
|
||||
'notice',
|
||||
|
|
@ -188,83 +212,93 @@ class ShoppingUser extends Model
|
|||
'wp_order_number' => 'int',
|
||||
];
|
||||
|
||||
|
||||
|
||||
//can null
|
||||
// can null
|
||||
public function member()
|
||||
{
|
||||
return $this->belongsTo('App\User','member_id');
|
||||
return $this->belongsTo('App\User', 'member_id');
|
||||
}
|
||||
public function auth_user()
|
||||
{
|
||||
return $this->belongsTo('App\User','auth_user_id');
|
||||
}
|
||||
|
||||
public function auth_user()
|
||||
{
|
||||
return $this->belongsTo('App\User', 'auth_user_id');
|
||||
}
|
||||
|
||||
public function billing_country()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Country','billing_country_id');
|
||||
return $this->belongsTo('App\Models\Country', 'billing_country_id');
|
||||
}
|
||||
|
||||
public function shipping_country()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Country','shipping_country_id');
|
||||
return $this->belongsTo('App\Models\Country', 'shipping_country_id');
|
||||
}
|
||||
|
||||
public function shopping_orders()
|
||||
{
|
||||
return $this->hasMany('App\Models\ShoppingOrder','shopping_user_id');
|
||||
return $this->hasMany('App\Models\ShoppingOrder', 'shopping_user_id');
|
||||
}
|
||||
|
||||
public function shopping_order()
|
||||
{
|
||||
return $this->hasOne('App\Models\ShoppingOrder','shopping_user_id');
|
||||
return $this->hasOne('App\Models\ShoppingOrder', 'shopping_user_id');
|
||||
}
|
||||
|
||||
public function getLocale(){
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->language ? $this->language : \App::getLocale();
|
||||
}
|
||||
|
||||
public function setNotice($key, $value){
|
||||
public function setNotice($key, $value)
|
||||
{
|
||||
$notice = $this->notice;
|
||||
$notice[$key] = $value;
|
||||
$this->notice = $notice;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function getNotice($key){
|
||||
public function getNotice($key)
|
||||
{
|
||||
return isset($this->notice[$key]) ? $this->notice[$key] : false;
|
||||
}
|
||||
|
||||
public function removeNotice($key){
|
||||
public function removeNotice($key)
|
||||
{
|
||||
$notice = $this->notice;
|
||||
if(isset($notice[$key])){
|
||||
if (isset($notice[$key])) {
|
||||
unset($notice[$key]);
|
||||
}
|
||||
$this->notice = $notice;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function firstEntryByNumber(){
|
||||
public function firstEntryByNumber()
|
||||
{
|
||||
|
||||
if($this->number>0){
|
||||
if($shopping_user = ShoppingUser::where('number', $this->number)->orderBy('created_at', 'ASC')->first()){
|
||||
if ($this->number > 0) {
|
||||
if ($shopping_user = ShoppingUser::where('number', $this->number)->orderBy('created_at', 'ASC')->first()) {
|
||||
return $shopping_user;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function lastEntryByNumber(){
|
||||
|
||||
if($this->number>0){
|
||||
if($shopping_user = ShoppingUser::where('number', $this->number)->orderBy('created_at', 'DESC')->first()){
|
||||
public function lastEntryByNumber()
|
||||
{
|
||||
|
||||
if ($this->number > 0) {
|
||||
if ($shopping_user = ShoppingUser::where('number', $this->number)->orderBy('created_at', 'DESC')->first()) {
|
||||
return $shopping_user;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOrderPaymentFor() {
|
||||
public function getOrderPaymentFor()
|
||||
{
|
||||
|
||||
switch($this->is_from){
|
||||
switch ($this->is_from) {
|
||||
case 'wizard':
|
||||
return 1;
|
||||
case 'membership':
|
||||
|
|
@ -276,34 +310,40 @@ class ShoppingUser extends Model
|
|||
case 'shopping':
|
||||
return 6;
|
||||
case 'extern':
|
||||
return 7;
|
||||
return 7;
|
||||
case 'collection':
|
||||
return 8;
|
||||
return 8;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function setIsForAttribute($value){
|
||||
if($value === 'abo-me' || $value === 'me'){
|
||||
public function setIsForAttribute($value)
|
||||
{
|
||||
if ($value === 'abo-me' || $value === 'me') {
|
||||
$this->attributes['is_for'] = 'me';
|
||||
|
||||
return;
|
||||
}
|
||||
if($value === 'ot-member' || $value === 'ot-customer' || $value === 'abo-ot-member' || $value === 'abo-ot-customer'){
|
||||
if ($value === 'ot-member' || $value === 'ot-customer' || $value === 'abo-ot-member' || $value === 'abo-ot-customer') {
|
||||
$this->attributes['is_for'] = 'ot';
|
||||
|
||||
return;
|
||||
}
|
||||
$this->attributes['is_for'] = $value;
|
||||
}
|
||||
|
||||
|
||||
public function getAPIShippedType() {
|
||||
if($this->shopping_order){
|
||||
public function getAPIShippedType()
|
||||
{
|
||||
if ($this->shopping_order) {
|
||||
return $this->shopping_order->getAPIShippedType();
|
||||
}
|
||||
return "free";
|
||||
|
||||
return 'free';
|
||||
}
|
||||
|
||||
public function getFullNameAsArray() {
|
||||
public function getFullNameAsArray()
|
||||
{
|
||||
return [
|
||||
'company' => $this->billing_company,
|
||||
'salutation' => $this->billing_salutation,
|
||||
|
|
@ -314,26 +354,75 @@ class ShoppingUser extends Model
|
|||
];
|
||||
}
|
||||
|
||||
public function getAllOrdersByMember(){
|
||||
public function getAllOrdersByMember()
|
||||
{
|
||||
return ShoppingUserService::getAllOrdersByMember($this);
|
||||
}
|
||||
|
||||
public function getDeliveryCountry($get_country = false){
|
||||
if($this->same_as_billing == 1){
|
||||
if($this->billing_country_id){
|
||||
if($get_country){
|
||||
public function getDeliveryCountry($get_country = false)
|
||||
{
|
||||
if ($this->same_as_billing == 1) {
|
||||
if ($this->billing_country_id) {
|
||||
if ($get_country) {
|
||||
return $this->billing_country;
|
||||
}
|
||||
|
||||
return $this->billing_country->getLocated();
|
||||
}
|
||||
}else{
|
||||
if($this->shipping_country_id){
|
||||
if($get_country){
|
||||
} else {
|
||||
if ($this->shipping_country_id) {
|
||||
if ($get_country) {
|
||||
return $this->shipping_country;
|
||||
}
|
||||
|
||||
return $this->shipping_country->getLocated();
|
||||
}
|
||||
}
|
||||
|
||||
return 'not set';
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft ob es sich um eine Packstation/Paketbox-Lieferung handelt
|
||||
*/
|
||||
public function isPackstationDelivery(): bool
|
||||
{
|
||||
return ! empty($this->shipping_postnumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Liefert die effektive Lieferadresse (berücksichtigt same_as_billing)
|
||||
*/
|
||||
public function getEffectiveShippingAddress(): array
|
||||
{
|
||||
if ($this->same_as_billing) {
|
||||
return [
|
||||
'salutation' => $this->billing_salutation,
|
||||
'company' => $this->billing_company,
|
||||
'firstname' => $this->billing_firstname,
|
||||
'lastname' => $this->billing_lastname,
|
||||
'address' => $this->billing_address,
|
||||
'address_2' => $this->billing_address_2,
|
||||
'zipcode' => $this->billing_zipcode,
|
||||
'city' => $this->billing_city,
|
||||
'country_id' => $this->billing_country_id,
|
||||
'phone' => $this->billing_phone,
|
||||
'postnumber' => null, // Bei same_as_billing keine Packstation
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'salutation' => $this->shipping_salutation,
|
||||
'company' => $this->shipping_company,
|
||||
'firstname' => $this->shipping_firstname,
|
||||
'lastname' => $this->shipping_lastname,
|
||||
'address' => $this->shipping_address,
|
||||
'address_2' => $this->shipping_address_2,
|
||||
'zipcode' => $this->shipping_zipcode,
|
||||
'city' => $this->shipping_city,
|
||||
'country_id' => $this->shipping_country_id,
|
||||
'phone' => $this->shipping_phone,
|
||||
'postnumber' => $this->shipping_postnumber,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue