mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 12:34:24 +00:00
98 lines
2.1 KiB
PHP
98 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
|
use App\Scopes\CustomerBookingsScope;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* Class Booking
|
|
* @package App\Models
|
|
*
|
|
* @property \App\Models\Company company_id
|
|
* @property \App\Models\Bank transferable_bank_id
|
|
* @property string marking
|
|
* @property string reference
|
|
* @property float fix_amount
|
|
* @property \App\Models\Currency convertible_currency_id
|
|
* @property \App\Models\Currency conversion_currency_id
|
|
*/
|
|
class Booking extends AbstractModel
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'bookings';
|
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function company(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(Company::class, 'company_id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function service(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(ServiceType::class, 'service_id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function bank(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(Bank::class, 'bank_id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function fixedCurrency(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(Currency::class, 'fix_currency_id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function convertibleCurrency(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(Currency::class, 'convertible_currency_id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function conversionCurrency(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(Currency::class, 'conversion_currency_id');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany
|
|
*/
|
|
public function transactions(): HasMany
|
|
{
|
|
return $this->HasMany(Transaction::class, 'booking_id');
|
|
}
|
|
|
|
protected static function booted()
|
|
{
|
|
if (auth()->user()->type === RoleTypes::USER) {
|
|
static::addGlobalScope(new CustomerBookingsScope);
|
|
}
|
|
}
|
|
|
|
|
|
}
|