mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-22 14:04:06 +00:00
89 lines
2.1 KiB
PHP
89 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Classes\General\Interfaces\Addressable;
|
|
use App\Classes\General\Interfaces\Contactable;
|
|
use App\Classes\General\Interfaces\Documentable;
|
|
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
|
use App\Classes\ValueObjects\Constants\BusinessType;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use PhpParser\Node\Expr\AssignOp\Mod;
|
|
|
|
/**
|
|
* Class CompanyConnection
|
|
* @package App\Models
|
|
*
|
|
* @property int $inviter_id
|
|
* @property int $invitee_id
|
|
* @property string $inviter_reference
|
|
* @property string $invitee_reference
|
|
* @property int $status
|
|
* @property bool $is_credit_term
|
|
*/
|
|
class CompanyConnection extends AbstractModel
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'company_connections';
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'deleted_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function inviter(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(CompanyModule::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function invitee(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(CompanyModule::class);
|
|
}
|
|
|
|
/**
|
|
* @param Builder $query
|
|
* @return Builder
|
|
*/
|
|
public function scopeApproved(Builder $query)
|
|
{
|
|
return $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
|
|
}
|
|
|
|
|
|
/**
|
|
* @return belongsToMany
|
|
*/
|
|
public function segments(): belongsToMany
|
|
{
|
|
return $this->belongsToMany(Segment::class, (new ConnectionSegment())->getTable(), 'company_connection_id', 'segment_id');
|
|
}
|
|
|
|
/**
|
|
* @return belongsToMany
|
|
*/
|
|
public function connectionSegments(): HasMany
|
|
{
|
|
return $this->hasMany(ConnectionSegment::class, 'company_connection_id');
|
|
}
|
|
|
|
}
|