Merge branch 'master' into 'remark-create-api'

# Conflicts:
#   app/Models/Container.php
#   app/Models/PackingList.php
#   routes/order.php
#   routes/packing_list.php
This commit is contained in:
omair saleh
2021-11-26 07:23:35 +00:00
139 changed files with 4292 additions and 579 deletions
-7
View File
@@ -4,18 +4,11 @@ namespace App\Models;
use App\Classes\General\Interfaces\Documentable;
use App\Classes\General\Interfaces\Contactable;
use App\Classes\Modules\ServiceTypes\DataTransferObjects\ServiceConfigurationsObject;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\BusinessType;
use App\Classes\ValueObjects\Constants\SegmentConstants;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Staudenmeir\EloquentHasManyDeep\HasManyDeep;
use Staudenmeir\EloquentHasManyDeep\HasRelationships;
+9
View File
@@ -60,4 +60,13 @@ class CompanyConnection extends AbstractModel
return $query->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
}
/**
* @return belongsToMany
*/
public function segments(): belongsToMany
{
return $this->belongsToMany(Segment::class, (new ConnectionSegment())->getTable(), 'company_connection_id', 'segment_id');
}
}
+11 -1
View File
@@ -6,6 +6,8 @@ use App\Classes\General\Interfaces\Addressable;
use App\Classes\General\Interfaces\Contactable;
use App\Classes\General\Interfaces\ContainerOwner;
use App\Classes\General\Interfaces\Documentable;
use App\Classes\General\Interfaces\Packable;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\BusinessType;
use Illuminate\Database\Eloquent\Builder;
@@ -28,7 +30,7 @@ use PhpParser\Node\Expr\AssignOp\Mod;
* @property integer type
* @property integer status
*/
class CompanyModule extends AbstractModel implements Addressable, Documentable, Contactable, ContainerOwner
class CompanyModule extends AbstractModel implements Addressable, Documentable, Contactable, ContainerOwner, Packable
{
use SoftDeletes;
@@ -60,6 +62,14 @@ class CompanyModule extends AbstractModel implements Addressable, Documentable,
return $this->morphMany(Address::class, 'owner');
}
/**
* @return MorphMany
*/
public function packingLists(): morphMany
{
return $this->morphMany(PackingList::class, 'owner');
}
/**
* @return belongsToMany
*/
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Segment
* @package App\Models
*
* @property string name
* @property string reference
*/
class ConnectionSegment extends AbstractModel
{
use SoftDeletes;
protected $table = 'connection_segments';
protected $dates = ['deleted_at'];
/**
* @return HasMany
*/
public function segments(): HasMany
{
return $this->HasMany(Segment::class, 'segment_id', 'id');
}
/**
* @return HasMany
*/
public function companyConnections(): HasMany
{
return $this->HasMany(CompanyConnection::class, 'company_connection_id', 'id');
}
}
+12 -11
View File
@@ -2,14 +2,15 @@
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\Relations\HasManyThrough;
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
class Container extends AbstractModel implements Transportable, Remarkable
{
use HasRelationships;
use SoftDeletes;
@@ -26,27 +27,27 @@ class Container extends AbstractModel implements Transportable
}
/**
* @return HasManyThrough
* @return hasManyDeep
*/
public function packages(): hasManyThrough
public function packages(): hasManyDeep
{
return $this->hasManyDeep(Package::class, [ContainerPackingList::class, PackingList::class], ['container_id', 'id', 'packing_list_id'], ['id', 'packing_list_id', 'id']);
return $this->hasManyDeepFromRelations($this->packingLists(), (new PackingList())->packages());
}
/**
* @return HasManyThrough
* @return hasManyDeep
*/
public function companyModules(): hasManyThrough
public function companyModules(): hasManyDeep
{
return $this->hasManyDeep(CompanyModule::class, [ContainerPackingList::class, PackingList::class, Order::class], ['container_id', 'id', 'id', 'id'], ['id', 'packing_list_id', null, 'company_module_id']);
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 HasManyThrough
* @return hasManyDeep
*/
public function orders(): hasManyThrough
public function orders(): hasManyDeep
{
return $this->hasManyDeep(Order::class, [ContainerPackingList::class, PackingList::class], ['container_id', 'id', 'id'], ['id', 'packing_list_id', null]);
return $this->hasManyDeep(Order::class, [ContainerPackingList::class, PackingList::class], ['container_id', 'id', 'id'], ['id', 'packing_list_id', 'owner_id']);
}
/**
+59
View File
@@ -96,4 +96,63 @@ class Order extends AbstractModel implements Addressable, Packable
{
return $this->addresses()->where('status','=',ApprovalStatus::APPROVED);
}
public function originWarehousePackages()
{
return $this->parcels()->shippingList()
->whereDoesntHave('shippingSchedules',
function($schedule) {
return $schedule->dispatched()
->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
}
);
}
public function inTransitPackages()
{
return $this->parcels()->shippingList()->Shipping()
->whereHas('shippingSchedules',
function($schedule) {
return $schedule->dispatched()
->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
}
)
->whereDoesntHave('container', function($container) {
return $container->where('containers.status', ApprovalStatus::COMPLETED);
}
);
}
public function destinationWarehousePackages()
{
return $this->parcels()->shippingList()
->whereHas('container',
function($container) {
return $container->where('containers.status', ApprovalStatus::COMPLETED);
}
)
->whereDoesntHave('deliverySchedules',
function($schedule) {
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
}
);
}
public function deliveredPackages()
{
return $this->parcels()->shippingList()
->whereHas('deliverySchedules',
function($schedule) {
return $schedule->dispatched()->whereIn('schedules.status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]);
}
);
}
/**
* @return morphMany
*/
public function transactions(): morphMany
{
return $this->morphMany(Transaction::class, 'owner');
}
}
+10 -1
View File
@@ -33,7 +33,15 @@ class Package extends AbstractModel
*/
public function order(): hasOneDeep
{
return $this->hasOneDeep(Order::class, [PackingList::class], ['id', ['owner_type', 'owner_id']], ['packing_list_id', null]);
return $this->hasOneDeep(Order::class, [PackingList::class], ['id', 'id'], ['packing_list_id', 'owner_id']);
}
/**
* @return hasOneDeep
*/
public function companyModule(): hasOneDeep
{
return $this->hasOneDeep(CompanyModule::class, [PackingList::class, Order::class], ['id', 'id', 'id'], ['packing_list_id', 'owner_id', 'company_module_id']);
}
/**
@@ -52,6 +60,7 @@ class Package extends AbstractModel
return $this->hasManyDeep(Schedule::class, [PackingList::class, ContainerPackingList::class, Container::class, Transport::class], ['id', 'packing_list_id', 'id', ['owner_type', 'owner_id'], ['owner_type', 'owner_id']], ['packing_list_id', 'id', 'container_id', null, null]);
}
/**
* @return HasManyThrough
*/
+7
View File
@@ -64,4 +64,11 @@ class PackingList extends AbstractModel implements Transportable, Steppable
return $this->morphMany(Remark::class, 'owner');
}
/**
* @return belongsToMany
*/
public function packing_list_owner()
{
return $this->BelongsToMany(PackingList::class, 'packing_list_owner', 'owner_packing_list_id', 'packing_list_id');
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PackingListOwner extends Model
{
use HasFactory;
}
+9
View File
@@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Remark extends AbstractModel
{
@@ -15,4 +16,12 @@ class Remark extends AbstractModel
{
return $this->morphTo();
}
/**
* @return BelongsTo
*/
public function commenter(): BelongsTo
{
return $this->BelongsTo(User::class, 'commenter_id', 'id');
}
}
+8
View File
@@ -27,4 +27,12 @@ class Segment extends AbstractModel
{
return $this->HasMany(SegmentConstant::class, 'segment_id', 'id');
}
/**
* @return belongsToMany
*/
public function companyConnections(): belongsToMany
{
return $this->belongsToMany(CompanyConnection::class, (new ConnectionSegment())->getTable(), 'segment_id', 'company_connection_id');
}
}
+10 -5
View File
@@ -16,12 +16,17 @@ class Transaction extends AbstractModel implements Documentable
{
protected $table = 'transactions';
/**
* @return BelongsTo
*/
public function booking(): BelongsTo
public function owner(): morphTo
{
return $this->BelongsTo( Booking::class, 'booking_id', 'id');
return $this->morphTo();
}
/**
* @return MorphMany
*/
public function order(): morphMany
{
return $this->morphMany(Order::class, 'owner');
}
/**
+1 -1
View File
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
class TransactionDetail extends AbstractModel
{
protected $table = 'transaction_detail';
protected $table = 'transaction_details';
/**
* @return BelongsTo
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class District
* @package App\Models
*
* @property \App\Models\User user_id
* @property string app_id
* @property int platform
*/
class UserSocialAccount extends AbstractModel
{
use SoftDeletes;
protected $table = 'user_social_accounts';
protected $dates = ['deleted_at'];
/**
* @return BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id', 'id');
}
}