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