94 lines
3.2 KiB
PHP
94 lines
3.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Services\Util;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class TravelCompany
|
|
*
|
|
* @property int $id
|
|
* @property string $name
|
|
* @property float $percentage
|
|
* @property bool $is_allowed_edit_commission
|
|
* @property bool $is_inhouse
|
|
* @property Collection|Booking[] $bookings
|
|
* @property Collection|BookingServiceItem[] $booking_service_items
|
|
* @package App\Models
|
|
* @property-read int|null $booking_service_items_count
|
|
* @property-read int|null $bookings_count
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereIsAllowedEditCommission($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereIsInhouse($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany wherePercentage($value)
|
|
* @property int|null $active
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereActive($value)
|
|
* @property array|null $contact_emails
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereContactEmails($value)
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelCompanyService[] $travel_company_services
|
|
* @property-read int|null $travel_company_services_count
|
|
* @mixin \Eloquent
|
|
*/
|
|
class TravelCompany extends Model
|
|
{
|
|
protected $connection = 'mysql';
|
|
|
|
protected $table = 'travel_company';
|
|
public $timestamps = false;
|
|
|
|
protected $casts = [
|
|
'percentage' => 'float',
|
|
'is_allowed_edit_commission' => 'bool',
|
|
'is_inhouse' => 'bool',
|
|
'active' => 'bool',
|
|
'contact_emails' => 'array'
|
|
];
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'percentage',
|
|
'is_allowed_edit_commission',
|
|
'is_inhouse',
|
|
'contact_emails',
|
|
'active'
|
|
];
|
|
|
|
public function bookings()
|
|
{
|
|
return $this->hasMany(Booking::class);
|
|
}
|
|
|
|
public function booking_service_items()
|
|
{
|
|
return $this->hasMany(BookingServiceItem::class);
|
|
}
|
|
public function travel_company_services()
|
|
{
|
|
return $this->hasMany(TravelCompanyService::class, 'travel_company_id', 'id')->orderBy('pos', 'DESC');
|
|
}
|
|
|
|
public function setPercentageAttribute($value)
|
|
{
|
|
$this->attributes['percentage'] = Util::_clean_float($value);
|
|
}
|
|
|
|
public function getPercentageAttribute()
|
|
{
|
|
return isset($this->attributes['percentage']) ? Util::_number_format($this->attributes['percentage']) : 0;
|
|
}
|
|
|
|
public function getPercentageRaw()
|
|
{
|
|
return isset($this->attributes['percentage']) ? $this->attributes['percentage'] : 0;
|
|
}
|
|
}
|