belongsTo('App\Models\Draft', 'draft_id'); } public function draft_type() { return $this->belongsTo('App\Models\DraftType', 'draft_type_id'); } public function _format_number($value){ return preg_replace("/[^0-9,]/", "", $value); } public function setPriceAdultAttribute($value) { $value = $this->_format_number($value); $this->attributes['price_adult'] = floatval(str_replace(',', '.', $value)); } public function getPriceAdultAttribute() { // 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator return number_format(($this->attributes['price_adult']), 2, ',', '.'); } public function getPriceAdultRaw() { return isset($this->attributes['price_adult']) ? $this->attributes['price_adult'] : 0; } public function setPriceChildrenAttribute($value) { $value = $this->_format_number($value); $this->attributes['price_children'] = floatval(str_replace(',', '.', $value)); } public function getPriceChildrenAttribute() { // 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator return number_format(($this->attributes['price_children']), 2, ',', '.'); } public function getPriceChildrenRaw() { return isset($this->attributes['price_children']) ? $this->attributes['price_children'] : 0; } }