'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 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 getAPIShippedType() { if($this->shopping_order){ return $this->shopping_order->getAPIShippedType(); } return "free"; } public function getOrderPaymentFor() { switch($this->is_from){ case 'wizard': return 1; case 'membership': return 2; case 'user_order': if($this->is_for === 'cr'){ return 3; } if($this->is_for === 'mp'){ return 4; } if($this->is_for === 'me'){ return 5; } if($this->is_for === 'ot'){ return 6; } return 0; case 'shopping': return $this->is_for === 'pr' ? 7 : 8; //7 Promotion case 'extern': return 10; } return 0; } }