hasMany('App\Models\BookingDraftItem', 'booking_id', 'id')->orderBy('pos', 'ASC'); } //on crm public function travel_agenda() { return $this->belongsTo('App\Models\TravelAgenda', 'travelagenda_id', 'id'); } public function travel_country() { return $this->belongsTo('App\Models\TravelCountry', 'travel_country_id', 'crm_id'); } public function lead() { return $this->belongsTo('App\Models\Lead', 'lead_id', 'id'); } public function sf_guard_user() { return $this->belongsTo('App\Models\SfGuardUser', 'sf_guard_user_id', 'id'); } public function arrangements() { return $this->hasMany('App\Models\Sym\Arrangement', 'booking_id', 'id')->orderBy('view_position', 'DESC'); } 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; } public function getStartDateFormat(){ if(!$this->attributes['start_date']){ return ""; } return Carbon::parse($this->attributes['start_date'])->format(\Util::formatDateDB()); } public function getEndDateFormat(){ if(!$this->attributes['end_date']){ return ""; } return Carbon::parse($this->attributes['end_date'])->format(\Util::formatDateDB()); } }