belongsTo('App\Models\Booking', 'booking_id'); } */ public function booking() { return $this->belongsTo('App\Models\Booking', 'booking_id'); } public function draft_item() { return $this->belongsTo('App\Models\DraftItem', 'draft_item_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 getStartDateAttribute(){ return isset($this->attributes['start_date']) ? Carbon::parse($this->attributes['start_date'])->format("d.m.Y") : ''; } public function getEndDateAttribute(){ return isset($this->attributes['end_date']) ? Carbon::parse($this->attributes['end_date'])->format("d.m.Y") : ''; } public function setStartDateAttribute($value) { if (!$value) { $this->attributes['start_date'] = null; } else { $this->attributes['start_date'] = (new Carbon($value))->format('Y-m-d'); } } public function setEndDateAttribute($value){ if (!$value) { $this->attributes['end_date'] = null; } else { $this->attributes['end_date'] = (new Carbon($value))->format('Y-m-d'); } } public function setPriceAttribute($value) { $value = $this->_format_number($value); $this->attributes['price'] = floatval(str_replace(',', '.', $value)); } public function getPriceAttribute() { // 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator return number_format(($this->attributes['price']), 2, ',', '.'); } public function getPriceRaw() { return isset($this->attributes['price']) ? $this->attributes['price'] : 0; } }