Fewos in CRM,
Fewo Clients Bookings create / edit / delelte via API in DB
This commit is contained in:
parent
aebfb0586a
commit
c0c2a1822c
55 changed files with 9787 additions and 1486 deletions
314
app/Models/TravelUserBookingFewo.php
Normal file
314
app/Models/TravelUserBookingFewo.php
Normal file
|
|
@ -0,0 +1,314 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
* Date: Thu, 21 Mar 2019 13:40:13 +0100.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Util;
|
||||
|
||||
/**
|
||||
* Class TravelUserBookingFewo
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_user_id
|
||||
* @property int $fewo_lodging_id
|
||||
* @property string $invoice_number
|
||||
* @property int $persons
|
||||
* @property int $adults
|
||||
* @property int $children
|
||||
* @property \Carbon\Carbon $booking_date
|
||||
* @property \Carbon\Carbon $from_date
|
||||
* @property \Carbon\Carbon $to_date
|
||||
* @property string $daily_prices
|
||||
* @property float $price_travel
|
||||
* @property float $price_deposit
|
||||
* @property float $price_service
|
||||
* @property float $price_total
|
||||
* @property int $travel_booking_fewo_channel_id
|
||||
* @property string $notice
|
||||
* @property bool $is_calendar_fewo_direct
|
||||
* @property bool $is_calendar_hrs
|
||||
* @property bool $is_calendar_stern_tours
|
||||
* @property int $status
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $deleted_at
|
||||
* @property \App\Models\FewoLodging $fewo_lodging
|
||||
* @property \App\Models\TravelBookingFewoChannel $travel_booking_fewo_channel
|
||||
* @property \App\Models\TravelUser $travel_user
|
||||
* @package App\Models
|
||||
* @method static bool|null forceDelete()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\TravelUserBookingFewo onlyTrashed()
|
||||
* @method static bool|null restore()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\TravelUserBookingFewo withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\TravelUserBookingFewo withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class TravelUserBookingFewo extends Model
|
||||
{
|
||||
use \Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
||||
|
||||
|
||||
protected static $statues = [
|
||||
0 => 'Anfrage von STERN TOURS',
|
||||
1 => 'Angebot versandt',
|
||||
2 => 'Rückfrage Agentur',
|
||||
3 => 'Rückfrage Kunden',
|
||||
5 => 'Nachfrage Angebot',
|
||||
7 => 'gebucht',
|
||||
8 => 'Absage',
|
||||
9 => 'Option',
|
||||
10 => 'Angebot erstellen',
|
||||
11 => 'Storno durch VA',
|
||||
12 => 'Storno durch Kunde',
|
||||
13 => 'Reiseanmeldung verschickt',
|
||||
];
|
||||
|
||||
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'travel_user_booking_fewos';
|
||||
|
||||
protected $casts = [
|
||||
'travel_user_id' => 'int',
|
||||
'fewo_lodging_id' => 'int',
|
||||
'persons' => 'int',
|
||||
'adults' => 'int',
|
||||
'children' => 'int',
|
||||
'daily_prices' => 'array', //!
|
||||
'price_travel' => 'float',
|
||||
'price_deposit' => 'float',
|
||||
'price_service' => 'float',
|
||||
'price_total' => 'float',
|
||||
'travel_booking_fewo_channel_id' => 'int',
|
||||
'is_calendar_fewo_direct' => 'bool',
|
||||
'is_calendar_hrs' => 'bool',
|
||||
'is_calendar_stern_tours' => 'bool',
|
||||
'status' => 'int'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'booking_date',
|
||||
'from_date',
|
||||
'to_date'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_user_id',
|
||||
'fewo_lodging_id',
|
||||
'invoice_number',
|
||||
'adults',
|
||||
'children',
|
||||
'persons',
|
||||
'booking_date',
|
||||
'from_date',
|
||||
'to_date',
|
||||
'daily_prices',
|
||||
'price_travel',
|
||||
'price_deposit',
|
||||
'price_service',
|
||||
'price_total',
|
||||
'travel_booking_fewo_channel_id',
|
||||
'notice',
|
||||
'is_calendar_fewo_direct',
|
||||
'is_calendar_hrs',
|
||||
'is_calendar_stern_tours',
|
||||
'status',
|
||||
'status_text'
|
||||
];
|
||||
|
||||
public function fewo_lodging()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\FewoLodging::class);
|
||||
}
|
||||
|
||||
public function travel_booking_fewo_channel()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\TravelBookingFewoChannel::class);
|
||||
}
|
||||
|
||||
public function travel_user()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\TravelUser::class);
|
||||
}
|
||||
|
||||
public function getStatuesName(){
|
||||
if(isset(self::$statues[$this->status])){
|
||||
return self::$statues[$this->status];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public function getPersonsAttribute($value)
|
||||
{
|
||||
$this->attributes['persons'] = $this->adults + $this->children;
|
||||
return $this->attributes['persons'];
|
||||
}
|
||||
|
||||
public function setPersonsAttribute( $value ) {
|
||||
|
||||
$this->attributes['persons'] = $this->adults + $this->children;
|
||||
|
||||
}
|
||||
|
||||
public function getAdultsAttribute()
|
||||
{
|
||||
return isset($this->attributes['adults']) ? $this->attributes['adults'] : 0;
|
||||
}
|
||||
|
||||
public function setAdultsAttribute( $value ) {
|
||||
|
||||
$this->attributes['persons'] = $this->adults + $this->children;
|
||||
$this->attributes['adults'] = $value;
|
||||
|
||||
}
|
||||
|
||||
public function getChildrenAttribute()
|
||||
{
|
||||
return isset($this->attributes['children']) ? $this->attributes['children'] : 0;
|
||||
}
|
||||
|
||||
public function setChildrenAttribute( $value ) {
|
||||
|
||||
$this->attributes['persons'] = $this->adults + $this->children;
|
||||
$this->attributes['children'] = $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function getStatuesOptions($setKey = false){
|
||||
$options = self::$statues;
|
||||
$ret = '';
|
||||
foreach ($options as $key => $option){
|
||||
$attr = ($key == $setKey) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$key.'" '.$attr.'>'.$option.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getBookingDateAttribute($value)
|
||||
{
|
||||
if(!$value){ return ""; }
|
||||
return Carbon::parse($value)->format(Util::formatDateDB());
|
||||
}
|
||||
|
||||
public function setBookingDateAttribute( $value ) {
|
||||
$this->attributes['booking_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
|
||||
//from_date
|
||||
public function getFromDateAttribute($value)
|
||||
{
|
||||
if(!$value){ return ""; }
|
||||
return Carbon::parse($value)->format(Util::formatDateDB());
|
||||
}
|
||||
public function setFromDateAttribute( $value ) {
|
||||
$this->attributes['from_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getFromDateRaw()
|
||||
{
|
||||
return isset($this->attributes['from_date']) ? $this->attributes['from_date'] : "";
|
||||
}
|
||||
|
||||
//to_date
|
||||
public function getToDateAttribute($value)
|
||||
{
|
||||
if(!$value){ return ""; }
|
||||
return Carbon::parse($value)->format(Util::formatDateDB());
|
||||
}
|
||||
public function setToDateAttribute( $value ) {
|
||||
$this->attributes['to_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
public function getToDateRaw()
|
||||
{
|
||||
return isset($this->attributes['to_date']) ? $this->attributes['to_date'] : "";
|
||||
}
|
||||
|
||||
//price_travel
|
||||
public function setPriceTravelAttribute($value)
|
||||
{
|
||||
$value = Util::_format_number($value);
|
||||
$this->attributes['price_travel'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
|
||||
public function getPriceTravelAttribute($value)
|
||||
{
|
||||
if(!$value){ return ""; }
|
||||
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
|
||||
return number_format(($this->attributes['price_travel']), 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getPriceTravelRaw()
|
||||
{
|
||||
return isset($this->attributes['price_travel']) ? $this->attributes['price_travel'] : 0;
|
||||
}
|
||||
|
||||
//price_deposit
|
||||
public function setPriceDepositAttribute($value)
|
||||
{
|
||||
$value = Util::_format_number($value);
|
||||
$this->attributes['price_deposit'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
|
||||
public function getPriceDepositAttribute($value)
|
||||
{
|
||||
if(!$value){ return ""; }
|
||||
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
|
||||
return number_format(($this->attributes['price_deposit']), 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getPriceDepositRaw()
|
||||
{
|
||||
return isset($this->attributes['price_deposit']) ? $this->attributes['price_deposit'] : 0;
|
||||
}
|
||||
|
||||
//price_service
|
||||
public function setPriceServiceAttribute($value)
|
||||
{
|
||||
$value = Util::_format_number($value);
|
||||
$this->attributes['price_service'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
|
||||
public function getPriceServiceAttribute($value)
|
||||
{
|
||||
if(!$value){ return ""; }
|
||||
|
||||
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
|
||||
return number_format(($this->attributes['price_service']), 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getPriceServiceRaw()
|
||||
{
|
||||
return isset($this->attributes['price_service']) ? $this->attributes['price_service'] : 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);
|
||||
}
|
||||
|
||||
public function getPriceTotalAttribute()
|
||||
{
|
||||
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
|
||||
$value = $this->getPriceDepositRaw() + $this->getPriceServiceRaw() + $this->getPriceTravelRaw();
|
||||
$this->attributes['price_total'] = floatval($value);
|
||||
return number_format(($this->attributes['price_total']), 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getPriceTotalRaw()
|
||||
{
|
||||
return isset($this->attributes['price_total']) ? $this->attributes['price_total'] : 0;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue