Booking, QI Content, Trees, Media

This commit is contained in:
Kevin Adametz 2019-10-02 20:03:55 +02:00
parent 1f340e96fa
commit 7fbac395a9
260 changed files with 27160 additions and 3773 deletions

View file

@ -114,6 +114,32 @@ class BookingDraftItem extends Model
return $this->belongsTo('App\Models\DraftType', 'draft_type_id');
}
public function getItemPrice(){
$adult = 0;
$children = 0;
$days_duration = 1;
if(isset($this->attributes['days_duration']) && in_array($this->draft_type_id, [36, 37])){
$days_duration = intval($this->days_duration);
}
if(isset($this->attributes['adult'])){
$adult = $this->attributes['price_adult'] * $this->attributes['adult'] * $days_duration;
}
if(isset($this->attributes['children'])){
$children = $this->attributes['price_children'] * $this->attributes['children'] * $days_duration;
}
/*
if(in_array($this->draft_type_id, [38, 39,40])){
$days_duration = $this->days_duration;
$price = $this->price;
}
*/
return ['adult'=>$adult, 'children'=>$children];
}
public function _format_number($value){
return preg_replace("/[^0-9,]/", "", $value);
}
@ -141,21 +167,66 @@ class BookingDraftItem extends Model
}
}
//price_adult
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 setPriceAdultRaw($value)
{
return $this->attributes['price_adult'] = $value;
}
//price_children
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;
}
public function setPriceChildrenRaw($value)
{
return $this->attributes['price_children'] = $value;
}
//price
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;
}
public function setPriceRaw($value)
{
return $this->attributes['price'] = $value;
}
}