User Groups and Rights, Fewo

This commit is contained in:
Kevin Adametz 2019-04-10 17:38:52 +02:00
parent c0c2a1822c
commit 26ecb09cdc
22 changed files with 1316 additions and 787 deletions

View file

@ -53,9 +53,6 @@ class TravelUserBookingFewo extends Model
{
use \Illuminate\Database\Eloquent\SoftDeletes;
protected static $statues = [
0 => 'Anfrage von STERN TOURS',
1 => 'Angebot versandt',
@ -79,6 +76,7 @@ class TravelUserBookingFewo extends Model
protected $casts = [
'travel_user_id' => 'int',
'fewo_lodging_id' => 'int',
'fewo_reservation_id' => 'int',
'persons' => 'int',
'adults' => 'int',
'children' => 'int',
@ -86,6 +84,7 @@ class TravelUserBookingFewo extends Model
'price_travel' => 'float',
'price_deposit' => 'float',
'price_service' => 'float',
'price_balance' => 'float',
'price_total' => 'float',
'travel_booking_fewo_channel_id' => 'int',
'is_calendar_fewo_direct' => 'bool',
@ -103,6 +102,7 @@ class TravelUserBookingFewo extends Model
protected $fillable = [
'travel_user_id',
'fewo_lodging_id',
'fewo_reservation_id',
'invoice_number',
'adults',
'children',
@ -114,6 +114,7 @@ class TravelUserBookingFewo extends Model
'price_travel',
'price_deposit',
'price_service',
'price_balance',
'price_total',
'travel_booking_fewo_channel_id',
'notice',
@ -129,6 +130,11 @@ class TravelUserBookingFewo extends Model
return $this->belongsTo(\App\Models\FewoLodging::class);
}
public function fewo_reservation()
{
return $this->belongsTo(\App\Models\FewoReservation::class, 'fewo_reservation_id');
}
public function travel_booking_fewo_channel()
{
return $this->belongsTo(\App\Models\TravelBookingFewoChannel::class);
@ -241,8 +247,7 @@ class TravelUserBookingFewo extends Model
public function getPriceTravelAttribute($value)
{
if(!$value){ return ""; }
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
if(!$value){ return 0; }
return number_format(($this->attributes['price_travel']), 2, ',', '.');
}
@ -260,8 +265,7 @@ class TravelUserBookingFewo extends Model
public function getPriceDepositAttribute($value)
{
if(!$value){ return ""; }
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
if(!$value){ return 0; }
return number_format(($this->attributes['price_deposit']), 2, ',', '.');
}
@ -279,9 +283,7 @@ class TravelUserBookingFewo extends Model
public function getPriceServiceAttribute($value)
{
if(!$value){ return ""; }
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
if(!$value){ return 0; }
return number_format(($this->attributes['price_service']), 2, ',', '.');
}
@ -290,19 +292,32 @@ class TravelUserBookingFewo extends Model
return isset($this->attributes['price_service']) ? $this->attributes['price_service'] : 0;
}
//price_balance
public function setPriceBalanceAttribute($value)
{
$value = Util::_format_number($value);
$this->attributes['price_balance'] = floatval(str_replace(',', '.', $value));
}
public function getPriceBalanceAttribute($value)
{
if(!$value){ return 0; }
return number_format(($this->attributes['price_balance']), 2, ',', '.');
}
public function getPriceBalanceRaw()
{
return isset($this->attributes['price_balance']) ? $this->attributes['price_balance'] : 0;
}
//price_total
public function setPriceTotalAttribute($value)
{
//$value = Util::_format_number($value);
$value = $this->getPriceDepositRaw() + $this->getPriceServiceRaw() + $this->getPriceTravelRaw();
$this->attributes['price_total'] = floatval($value);
$value = Util::_format_number($value);
$this->attributes['price_total'] = floatval(str_replace(',', '.', $value));
}
public function getPriceTotalAttribute()
public function getPriceTotalAttribute($value)
{
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
$value = $this->getPriceDepositRaw() + $this->getPriceServiceRaw() + $this->getPriceTravelRaw();
$this->attributes['price_total'] = floatval($value);
if(!$value){ return 0; }
return number_format(($this->attributes['price_total']), 2, ',', '.');
}