49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?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;
|
|
}
|
|
|
|
}
|