mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
634d4b8b7d
# Conflicts: # app/Models/Container.php # app/Models/PackingList.php # routes/order.php # routes/packing_list.php
69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Classes\General\Interfaces\Remarkable;
|
|
use App\Classes\General\Interfaces\Transportable;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
|
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
|
|
|
class Container extends AbstractModel implements Transportable, Remarkable
|
|
{
|
|
use HasRelationships;
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'containers';
|
|
|
|
protected $fillable = ['status'];
|
|
|
|
protected $dates = ['loading_date'];
|
|
|
|
public function packingLists(): belongsToMany
|
|
{
|
|
return $this->belongsToMany(PackingList::class, ContainerPackingList::class, 'container_id', 'packing_list_id');
|
|
}
|
|
|
|
/**
|
|
* @return hasManyDeep
|
|
*/
|
|
public function packages(): hasManyDeep
|
|
{
|
|
return $this->hasManyDeepFromRelations($this->packingLists(), (new PackingList())->packages());
|
|
}
|
|
|
|
/**
|
|
* @return hasManyDeep
|
|
*/
|
|
public function companyModules(): hasManyDeep
|
|
{
|
|
return $this->hasManyDeep(CompanyModule::class, [ContainerPackingList::class, PackingList::class, Order::class], ['container_id', 'id', 'id', 'id'], ['id', 'packing_list_id', 'owner_id', 'company_module_id']);
|
|
}
|
|
|
|
/**
|
|
* @return hasManyDeep
|
|
*/
|
|
public function orders(): hasManyDeep
|
|
{
|
|
return $this->hasManyDeep(Order::class, [ContainerPackingList::class, PackingList::class], ['container_id', 'id', 'id'], ['id', 'packing_list_id', 'owner_id']);
|
|
}
|
|
|
|
/**
|
|
* @return MorphMany
|
|
*/
|
|
public function transports(): morphMany
|
|
{
|
|
return $this->morphMany(Transport::class, 'owner');
|
|
}
|
|
|
|
/**
|
|
* @return MorphMany
|
|
*/
|
|
public function remarks(): morphMany
|
|
{
|
|
return $this->morphMany(Remark::class, 'owner');
|
|
}
|
|
}
|