update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
339
dev/app-bak/Models/ShoppingUser.php
Normal file
339
dev/app-bak/Models/ShoppingUser.php
Normal file
|
|
@ -0,0 +1,339 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\ShoppingUserService;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* App\Models\ShoppingUser
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $auth_user_id
|
||||
* @property string|null $billing_salutation
|
||||
* @property string|null $billing_company
|
||||
* @property string|null $billing_firstname
|
||||
* @property string|null $billing_lastname
|
||||
* @property string|null $billing_address
|
||||
* @property string|null $billing_address_2
|
||||
* @property string|null $billing_zipcode
|
||||
* @property string|null $billing_city
|
||||
* @property int $billing_country_id
|
||||
* @property string|null $billing_phone
|
||||
* @property string|null $billing_email
|
||||
* @property int $accepted_data_checkbox
|
||||
* @property int $same_as_billing
|
||||
* @property string|null $shipping_salutation
|
||||
* @property string|null $shipping_company
|
||||
* @property string|null $shipping_firstname
|
||||
* @property string|null $shipping_lastname
|
||||
* @property string|null $shipping_address
|
||||
* @property string|null $shipping_address_2
|
||||
* @property string|null $shipping_zipcode
|
||||
* @property string|null $shipping_city
|
||||
* @property int $shipping_country_id
|
||||
* @property string|null $shipping_phone
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrder[] $Shopping_orders
|
||||
* @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()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereAcceptedDataCheckbox($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereAuthUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingAddress($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingAddress2($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingCity($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingCompany($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingFirstname($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingLastname($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingPhone($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingSalutation($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereBillingZipcode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereSameAsBilling($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingAddress($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingAddress2($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingCity($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingCompany($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingFirstname($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingLastname($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingPhone($value)
|
||||
* @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
|
||||
{
|
||||
protected $table = 'shopping_users';
|
||||
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'auth_user_id',
|
||||
'member_id',
|
||||
'number',
|
||||
'is_like',
|
||||
'language',
|
||||
'billing_salutation',
|
||||
'billing_company',
|
||||
'billing_firstname',
|
||||
'billing_lastname',
|
||||
'billing_address',
|
||||
'billing_address_2',
|
||||
'billing_zipcode',
|
||||
'billing_city',
|
||||
'billing_country_id',
|
||||
'billing_phone',
|
||||
'billing_email',
|
||||
'faker_mail',
|
||||
'shipping_email',
|
||||
'accepted_data_checkbox',
|
||||
'same_as_billing',
|
||||
'shipping_salutation',
|
||||
'shipping_company',
|
||||
'shipping_firstname',
|
||||
'shipping_lastname',
|
||||
'shipping_address',
|
||||
'shipping_address_2',
|
||||
'shipping_zipcode',
|
||||
'shipping_city',
|
||||
'shipping_country_id',
|
||||
'shipping_phone',
|
||||
'has_buyed',
|
||||
'subscribed',
|
||||
'notice',
|
||||
'remarks',
|
||||
'mode',
|
||||
'is_for',
|
||||
'is_from',
|
||||
'shopping_user_id',
|
||||
'homeparty_id',
|
||||
'shopping_collect_order_id',
|
||||
'wp_order_number',
|
||||
'wp_order_date',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'notice' => 'array',
|
||||
'is_like' => 'bool',
|
||||
'faker_mail' => 'bool',
|
||||
'accepted_data_checkbox' => 'bool',
|
||||
'same_as_billing' => 'bool',
|
||||
'has_buyed' => 'bool',
|
||||
'subscribed' => 'bool',
|
||||
'wp_order_number' => 'int',
|
||||
];
|
||||
|
||||
|
||||
|
||||
//can null
|
||||
public function member()
|
||||
{
|
||||
return $this->belongsTo('App\User','member_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');
|
||||
}
|
||||
|
||||
public function shipping_country()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Country','shipping_country_id');
|
||||
}
|
||||
|
||||
public function shopping_orders()
|
||||
{
|
||||
return $this->hasMany('App\Models\ShoppingOrder','shopping_user_id');
|
||||
}
|
||||
|
||||
public function shopping_order()
|
||||
{
|
||||
return $this->hasOne('App\Models\ShoppingOrder','shopping_user_id');
|
||||
}
|
||||
|
||||
public function getLocale(){
|
||||
return $this->language ? $this->language : \App::getLocale();
|
||||
}
|
||||
|
||||
public function setNotice($key, $value){
|
||||
$notice = $this->notice;
|
||||
$notice[$key] = $value;
|
||||
$this->notice = $notice;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function getNotice($key){
|
||||
return isset($this->notice[$key]) ? $this->notice[$key] : false;
|
||||
}
|
||||
|
||||
public function removeNotice($key){
|
||||
$notice = $this->notice;
|
||||
if(isset($notice[$key])){
|
||||
unset($notice[$key]);
|
||||
}
|
||||
$this->notice = $notice;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function firstEntryByNumber(){
|
||||
|
||||
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()){
|
||||
return $shopping_user;
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOrderPaymentFor() {
|
||||
|
||||
switch($this->is_from){
|
||||
case 'wizard':
|
||||
return 1;
|
||||
case 'membership':
|
||||
return 2;
|
||||
case 'user_order':
|
||||
return ($this->is_for === 'me' || $this->is_for === 'abo_me') ? 3 : 4;
|
||||
case 'homeparty':
|
||||
return 5;
|
||||
case 'shopping':
|
||||
return 6;
|
||||
case 'extern':
|
||||
return 7;
|
||||
case 'collection':
|
||||
return 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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'){
|
||||
$this->attributes['is_for'] = 'ot';
|
||||
return;
|
||||
}
|
||||
$this->attributes['is_for'] = $value;
|
||||
}
|
||||
|
||||
|
||||
public function getAPIShippedType() {
|
||||
if($this->shopping_order){
|
||||
return $this->shopping_order->getAPIShippedType();
|
||||
}
|
||||
return "free";
|
||||
}
|
||||
|
||||
public function getFullNameAsArray() {
|
||||
return [
|
||||
'company' => $this->billing_company,
|
||||
'salutation' => $this->billing_salutation,
|
||||
'firstname' => $this->billing_firstname,
|
||||
'lastname' => $this->billing_lastname,
|
||||
'email' => $this->billing_email,
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
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){
|
||||
return $this->billing_country;
|
||||
}
|
||||
return $this->billing_country->getLocated();
|
||||
}
|
||||
}else{
|
||||
if($this->shipping_country_id){
|
||||
if($get_country){
|
||||
return $this->shipping_country;
|
||||
}
|
||||
return $this->shipping_country->getLocated();
|
||||
}
|
||||
}
|
||||
return 'not set';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue