mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
add: new model files, CompanyEmployee and CompanyModule based on new tables.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* Class CompanyEmployee
|
||||
* @package App\Models
|
||||
*
|
||||
* @property \App\Models\companyModule company_module_id
|
||||
* @property \App\Models\User user_id
|
||||
* @property integer role_id
|
||||
* @property integer status
|
||||
*/
|
||||
class CompanyEmployee extends AbstractModel
|
||||
{
|
||||
protected $table = 'company_employees';
|
||||
|
||||
/**
|
||||
* @return HasMany
|
||||
*/
|
||||
public function companyModule(): HasMany
|
||||
{
|
||||
return $this->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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?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')));
|
||||
// });
|
||||
// }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user