diff --git a/app/Models/CompanyEmployee.php b/app/Models/CompanyEmployee.php new file mode 100644 index 00000000..fc6ebfa4 --- /dev/null +++ b/app/Models/CompanyEmployee.php @@ -0,0 +1,36 @@ +HasMany(CompanyModule::class, 'company_module_id', 'id'); + } + + /** + * @return \Illuminate\Database\Eloquent\Relations\HasOne + **/ + public function user(): HasOne + { + return $this->hasOne(User::class, 'user_id', 'id'); + } +} diff --git a/app/Models/CompanyModule.php b/app/Models/CompanyModule.php new file mode 100644 index 00000000..9c6026d8 --- /dev/null +++ b/app/Models/CompanyModule.php @@ -0,0 +1,103 @@ +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'))); + // }); + // } + +}