mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
118 lines
3.0 KiB
PHP
118 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Classes\General\Traits\LogData;
|
|
use Eloquent;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\Classes\General\Interfaces\Documentable;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
|
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
|
use App\Classes\General\Interfaces\Transactionable;
|
|
use Staudenmeir\EloquentHasManyDeep\HasTableAlias;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
/**
|
|
* App\Models\Group
|
|
*
|
|
* @property-read Currency|null $currency
|
|
* @property-read Collection|Document[] $documents
|
|
* @property-read int|null $documents_count
|
|
* @property-read CompanyModule|null $issuerCompany
|
|
* @property-read Currency|null $original_currency
|
|
* @property-read CompanyModule|null $receiverCompany
|
|
* @property-read Collection|Transaction[] $transactions
|
|
* @property-read int|null $transactions_count
|
|
* @method static Builder|Group newModelQuery()
|
|
* @method static Builder|Group newQuery()
|
|
* @method static Builder|Group query()
|
|
* @mixin Eloquent
|
|
*/
|
|
class Group extends Model implements Documentable, Transactionable
|
|
{
|
|
use HasRelationships;
|
|
use HasTableAlias;
|
|
|
|
use \Staudenmeir\EloquentHasManyDeep\HasTableAlias;
|
|
use SoftDeletes;
|
|
|
|
/**
|
|
* @return MorphMany
|
|
*/
|
|
public function transactions(): MorphMany
|
|
{
|
|
return $this->MorphMany(GroupTransaction::class, 'group');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany
|
|
*/
|
|
public function groupTransactions(): HasMany
|
|
{
|
|
return $this->hasMany(GroupTransaction::class);
|
|
}
|
|
|
|
/**
|
|
* @return MorphMany
|
|
*/
|
|
public function documents(): morphMany
|
|
{
|
|
return $this->morphMany(Document::class, 'owner');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function currency(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(Currency::class, 'currency_id', 'id');
|
|
}
|
|
|
|
|
|
/**
|
|
* @return HasManyDeep
|
|
*/
|
|
public function transferFees(): HasManyDeep
|
|
{
|
|
return $this->HasManyDeep(Transaction::class, [GroupTransaction::class, Transaction::class.' as alias'], ['group_id', ['owner_type', 'owner_id'], ['owner_type', 'owner_id']], ['id', null, null]);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function issuerCompany(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(CompanyModule::class, 'issuer', 'id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function receiverCompany(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(CompanyModule::class, 'receiver', 'id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function original_currency(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(Currency::class, 'original_currency_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* @return hasOne
|
|
*/
|
|
public function payment()
|
|
{
|
|
return $this->hasOne(Transaction::class, 'payment_reference', 'reference');
|
|
}
|
|
}
|