mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 20:44:01 +00:00
96 lines
2.1 KiB
PHP
96 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Classes\General\Interfaces\Addressable;
|
|
use App\Classes\General\Interfaces\Documentable;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
/**
|
|
* Class CompanyModule
|
|
* @package App\Models
|
|
*
|
|
* @property \App\Models\Company company_id
|
|
* @property integer type
|
|
* @property integer status
|
|
*/
|
|
class CompanyModule extends AbstractModel implements Addressable, Documentable
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'company_modules';
|
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
/**
|
|
* @return BelongsTo
|
|
*/
|
|
public function company(): BelongsTo
|
|
{
|
|
return $this->BelongsTo(Company::class, 'company_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* @return MorphMany
|
|
*/
|
|
public function contacts(): morphMany
|
|
{
|
|
return $this->morphMany(Contact::class, 'owner');
|
|
}
|
|
|
|
/**
|
|
* @return MorphMany
|
|
*/
|
|
public function addresses(): morphMany
|
|
{
|
|
return $this->morphMany(Address::class, 'owner');
|
|
}
|
|
|
|
/**
|
|
* @return belongsToMany
|
|
*/
|
|
public function employees(): belongsToMany
|
|
{
|
|
return $this->belongsToMany(User::class, (new CompanyEmployee())->getTable(), 'company_module_id', 'user_id');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany
|
|
*/
|
|
public function orders(): HasMany
|
|
{
|
|
return $this->HasMany(Order::class, 'company_module_id');
|
|
}
|
|
|
|
/**
|
|
* @return belongsToMany
|
|
*/
|
|
public function segments(): belongsToMany
|
|
{
|
|
return $this->belongsToMany(Segment::class, (new SegmentCompany())->getTable(), 'company_id', 'segment_id');
|
|
}
|
|
|
|
/**
|
|
* @return MorphMany
|
|
*/
|
|
public function documents(): morphMany
|
|
{
|
|
return $this->morphMany(Document::class, 'owner');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany
|
|
*/
|
|
public function banks(): HasMany
|
|
{
|
|
return $this->HasMany(Bank::class, 'company_id');
|
|
}
|
|
|
|
}
|