17 nov 2018

This commit is contained in:
Kevin Adametz 2018-11-17 02:03:59 +01:00
parent 0c9a118281
commit 765d6a2f6b
52 changed files with 3200 additions and 229 deletions

49
app/Models/Booking.php Normal file
View file

@ -0,0 +1,49 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Booking extends Model
{
protected $connection = 'mysql';
protected $table = 'booking';
/*protected $fillable = [
'pos',
];*/
public function booking_draft_items()
{
return $this->hasMany('App\Models\BookingDraftItem', 'booking_id', 'id')->orderBy('pos', 'ASC');
}
public function findBeforeDraftItemRelation($reid)
{
$before = false;
foreach($this->booking_draft_items as $booking_draft_items) {
if ($booking_draft_items->id == $reid) {
return $before;
}
$before = $booking_draft_items;
}
return false;
}
public function findAfterDraftItemRelation($reid)
{
$next = false;
foreach($this->booking_draft_items as $booking_draft_items) {
if($next){
return $booking_draft_items;
}
if ($booking_draft_items->id == $reid) {
$next = true;
}
}
return false;
}
}

View file

@ -0,0 +1,130 @@
<?php
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\BookingDraftItem
*
* @property int $id
* @property int $booking_id
* @property int $travel_program_id
* @property int|null $travel_class_id
* @property int|null $draft_item_id
* @property int|null $draft_type_id
* @property string|null $request_date
* @property int|null $days_start
* @property int|null $days_duration
* @property string|null $start_date
* @property string|null $end_date
* @property string|null $service
* @property float|null $price_adult
* @property int|null $adult
* @property float|null $price_children
* @property int|null $children
* @property int|null $pos
* @property int $in_pdf
* @property int $status
* @property int $comfort
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\DraftItem|null $draft_item
* @property-read \App\Models\DraftType|null $draft_type
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereAdult($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereBookingId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereChildren($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereComfort($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereDaysDuration($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereDaysStart($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereDraftItemId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereDraftTypeId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereEndDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereInPdf($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem wherePos($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem wherePriceAdult($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem wherePriceChildren($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereRequestDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereService($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereStartDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereStatus($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereTravelClassId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereTravelProgramId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingDraftItem whereUpdatedAt($value)
* @mixin \Eloquent
*/
class BookingDraftItem extends Model
{
protected $connection = 'mysql';
protected $table = 'booking_draft_items';
protected $fillable = [
'booking_id',
'travel_program_id',
'travel_class_id',
'draft_item_id',
'draft_type_id',
'request_date',
'days_start',
'days_duration',
'start_date',
'end_date',
'service',
'price_adult',
'adult',
'price_children',
'children',
'pos',
'in_pdf',
'comfort',
];
/* public function booking()
{
return $this->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 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');
}
}
}

View file

@ -55,6 +55,8 @@ class DraftItem extends Model
'pos',
];
public function draft()
{
return $this->belongsTo('App\Models\Draft', 'draft_id');

View file

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class TravelCountry extends Model
{
//use the connection to sec. Datebase sterntours
protected $connection = 'mysql_stern';
protected $table = 'travel_country';
protected $fillable = [
'name',
'html_information',
];
public $timestamps = false;
public function travel_program_country()
{
return $this->hasOne('App\Models\TravelProgramCountry', 'country_id', 'id');
}
}

View file

@ -129,6 +129,11 @@ class TravelProgram extends Model
return $this->hasMany('App\Models\TravelProgramDraft', 'travel_program_id', 'id');
}
public function travel_program_country()
{
return $this->hasOne('App\Models\TravelProgramCountry', 'program_id', 'id');
}
public function getWeekdaysArray(){
if($this->weekdays){
return explode(',', $this->weekdays);

View file

@ -0,0 +1,31 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class TravelProgramCountry extends Model
{
//use the connection to sec. Datebase sterntours
protected $connection = 'mysql_stern';
protected $table = 'travel_program_country';
protected $fillable = [
'program_id',
'country_id',
];
public $timestamps = false;
public function travel_program()
{
return $this->belongsTo('App\Models\TravelProgram', 'program_id');
}
public function travel_country()
{
return $this->belongsTo('App\Models\TravelCountry', 'country_id');
}
}