Files
shipping-portal/app/Models/CompanyModule.php
T

104 lines
2.9 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
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
{
use SoftDeletes;
protected $table = 'company_modules';
protected $dates = ['deleted_at'];
/**
* @return MorphMany
*/
public function contacts(): morphMany
{
return $this->morphMany(Contact::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 addresses(): HasMany
// {
// return $this->HasMany(Address::class, 'company_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');
// }
// /**
// * @return HasMany
// */
// public function bookings(): HasMany
// {
// return $this->HasMany(Booking::class, 'company_id');
// }
// /**
// * @return Builder
// */
// public function services(): Builder {
// return ServiceType::where('status', ApprovalStatus::APPROVED)->whereHas('constants', function($query) {
// $query->Where(function($query){
// $query->where('reference', SegmentConstants::SERVICE_TYPE)->where('detail->is_active', true);
// })->orWhere(function($query) {
// $query->where('reference', SegmentConstants::CUSTOM_SERVICE_TYPE)->where('detail->is_active', true)->whereIn('segment_id', $this->segments->pluck('id'));
// });
// });
// }
// public function servicesConfigurations(): Collection {
// return $this->services()->get()->map(function($service) {
// return new ServiceConfigurationsObject($service,
// $service->constants->where('reference', SegmentConstants::SERVICE_TYPE)->first(),
// $service->constants->where('reference', SegmentConstants::CUSTOM_SERVICE_TYPE)->whereIn('segment_id', $this->segments->pluck('id')));
// });
// }
}