mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-22 14:04:21 +00:00
update replica packages logic and over weight price announcement
This commit is contained in:
@@ -26,7 +26,7 @@ class Package extends AbstractModel
|
||||
/**
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function packingLists(): BelongsTo
|
||||
public function packingList(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PackingList::class, 'packing_list_id');
|
||||
}
|
||||
|
||||
@@ -4,16 +4,21 @@ namespace App\Models;
|
||||
|
||||
use App\Classes\General\Interfaces\Steppable;
|
||||
use App\Classes\General\Interfaces\Transportable;
|
||||
use App\Classes\ValueObjects\Constants\ApprovalStatus;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
|
||||
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
|
||||
|
||||
class PackingList extends AbstractModel implements Transportable, Steppable
|
||||
{
|
||||
use SoftDeletes;
|
||||
use HasRelationships;
|
||||
|
||||
protected $table = 'packing_lists';
|
||||
|
||||
@@ -71,4 +76,49 @@ class PackingList extends AbstractModel implements Transportable, Steppable
|
||||
{
|
||||
return $this->BelongsToMany(PackingList::class, 'packing_list_owner', 'owner_packing_list_id', 'packing_list_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function packingLists(): morphMany
|
||||
{
|
||||
return $this->morphMany(PackingList::class, 'owner');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hasManyDeep
|
||||
*/
|
||||
public function shippingTransports(): hasManyDeep
|
||||
{
|
||||
return $this->hasManyDeep(Transport::class, [ContainerPackingList::class, Container::class], ['packing_list_id', 'id', ['owner_type', 'owner_id']], ['id', 'container_id', null]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hasManyDeep
|
||||
*/
|
||||
public function shippingSchedules(): hasManyDeep
|
||||
{
|
||||
return $this->hasManyDeep(Schedule::class, [ContainerPackingList::class, Container::class, Transport::class], ['packing_list_id', 'id', ['owner_type', 'owner_id'], ['owner_type', 'owner_id']], ['id', 'container_id', null, null]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return hasManyDeep
|
||||
*/
|
||||
public function deliverySchedules(): hasManyDeep
|
||||
{
|
||||
return $this->hasManyDeep(Schedule::class, [Transport::class], [['owner_type', 'owner_id'], ['owner_type', 'owner_id']], [null, null]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeShipping($query){
|
||||
return $query->whereHas('shippingSchedules', function($schedule){
|
||||
return $schedule->where('etd', '<', Carbon::now())->where('schedules.status', ApprovalStatus::APPROVED);
|
||||
})->whereDoesntHave('shippingTransports', function($transport){
|
||||
return $transport->where('transport_arrangements.status', ApprovalStatus::COMPLETED);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user