mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-28 00:44:04 +00:00
111 lines
3.6 KiB
PHP
111 lines
3.6 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 Eloquent;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
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 Illuminate\Support\Carbon;
|
|
use PhpParser\Node\Expr\AssignOp\Mod;
|
|
use Spatie\Activitylog\Models\Activity;
|
|
|
|
/**
|
|
* Class CompanyModule
|
|
*
|
|
* @package App\Models
|
|
* @property Company company_id
|
|
* @property integer type
|
|
* @property integer status
|
|
* @property int $id
|
|
* @property int $inviter_id
|
|
* @property int $invitee_id
|
|
* @property string $inviter_reference
|
|
* @property string $invitee_reference
|
|
* @property Carbon|null $deleted_at
|
|
* @property Carbon|null $created_at
|
|
* @property Carbon|null $updated_at
|
|
* @property-read Collection|Activity[] $activities
|
|
* @property-read int|null $activities_count
|
|
* @property-read Model|Eloquent $causer
|
|
* @property-read CompanyModule $invitee
|
|
* @property-read CompanyModule $inviter
|
|
* @property-read Collection|Segment[] $segments
|
|
* @property-read int|null $segments_count
|
|
* @property-read Model|Eloquent $subject
|
|
* @property-read Model|Eloquent $target
|
|
* @method static Builder|CompanyConnection approved()
|
|
* @method static Builder|CompanyConnection newModelQuery()
|
|
* @method static Builder|CompanyConnection newQuery()
|
|
* @method static \Illuminate\Database\Query\Builder|CompanyConnection onlyTrashed()
|
|
* @method static Builder|CompanyConnection query()
|
|
* @method static Builder|CompanyConnection whereCreatedAt($value)
|
|
* @method static Builder|CompanyConnection whereDeletedAt($value)
|
|
* @method static Builder|CompanyConnection whereId($value)
|
|
* @method static Builder|CompanyConnection whereInviteeId($value)
|
|
* @method static Builder|CompanyConnection whereInviteeReference($value)
|
|
* @method static Builder|CompanyConnection whereInviterId($value)
|
|
* @method static Builder|CompanyConnection whereInviterReference($value)
|
|
* @method static Builder|CompanyConnection whereStatus($value)
|
|
* @method static Builder|CompanyConnection whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Query\Builder|CompanyConnection withTrashed()
|
|
* @method static \Illuminate\Database\Query\Builder|CompanyConnection withoutTrashed()
|
|
* @mixin Eloquent
|
|
*/
|
|
class CompanyConnection extends AbstractModel
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'company_connections';
|
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
/**
|
|
* @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');
|
|
}
|
|
|
|
}
|