'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, ]; } }