diff --git a/app/Classes/General/Interfaces/Addressable.php b/app/Classes/General/Interfaces/Addressable.php new file mode 100644 index 00000000..30a35cd0 --- /dev/null +++ b/app/Classes/General/Interfaces/Addressable.php @@ -0,0 +1,13 @@ +fetchesDistrict->execute(['id' => $request->input('district_id')]); - $object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code')); + $object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'), $request->input('reference')); $this->canCreateAddress->passes($object); - $query = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object); + $address = $this->createsAddress->execute($this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]), $object); - return $this->resourceResponse(new AddressResource($query)); + return $this->resourceResponse(new AddressResource($address)); } diff --git a/app/Classes/Modules/Addresses/ControllersLogic/DeleteAddressLogic.php b/app/Classes/Modules/Addresses/ControllersLogic/DeleteAddressLogic.php index 3a3593aa..3478dece 100644 --- a/app/Classes/Modules/Addresses/ControllersLogic/DeleteAddressLogic.php +++ b/app/Classes/Modules/Addresses/ControllersLogic/DeleteAddressLogic.php @@ -50,23 +50,20 @@ class DeleteAddressLogic extends AbstractControllerLogic /** * @param Request $request * @return JsonResponse - * @throws ErrorException + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse { - try { - $this->canDeleteAddress->passes(); + $this->canDeleteAddress->passes(); - $query = $this->fetchesAddress->execute(['id' => $request->route('id')]); + $query = $this->fetchesAddress->execute(['id' => $request->route('id')]); - $this->deletesAddress->execute($query); + $this->deletesAddress->execute($query); - return $this->response([]); - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } + return $this->response([]); } diff --git a/app/Classes/Modules/Addresses/ControllersLogic/FetchAddressLogic.php b/app/Classes/Modules/Addresses/ControllersLogic/FetchAddressLogic.php index 12320e0f..2b1ae32e 100644 --- a/app/Classes/Modules/Addresses/ControllersLogic/FetchAddressLogic.php +++ b/app/Classes/Modules/Addresses/ControllersLogic/FetchAddressLogic.php @@ -45,21 +45,16 @@ class FetchAddressLogic extends AbstractControllerLogic /** * @param Request $request * @return JsonResponse - * @throws ErrorException + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse { - try { + $this->canFetchAddress->passes(); - $this->canFetchAddress->passes(); + $query = $this->fetchesAddress->execute(['id' => $request->route('id')]); - $query = $this->fetchesAddress->execute(['id' => $request->route('id')]); - - return $this->resourceResponse(new AddressResource($query)); - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } + return $this->resourceResponse(new AddressResource($query)); } diff --git a/app/Classes/Modules/Addresses/ControllersLogic/ListAddressesLogic.php b/app/Classes/Modules/Addresses/ControllersLogic/ListAddressesLogic.php index 57e3a2f0..71e3b80d 100644 --- a/app/Classes/Modules/Addresses/ControllersLogic/ListAddressesLogic.php +++ b/app/Classes/Modules/Addresses/ControllersLogic/ListAddressesLogic.php @@ -45,21 +45,18 @@ class ListAddressesLogic extends AbstractControllerLogic /** * @param Request $request * @return JsonResponse - * @throws ErrorException + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse { - try { - $this->canListAddresses->passes(); + $this->canListAddresses->passes(); - $query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters'))); + $query = $this->listsAddresses->execute($this->listsAddresses->deserializeFilters($request->input('filters'))); - return $this->collectionResponse(AddressResource::collection($query)); - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } + return $this->collectionResponse(AddressResource::collection($query)); } diff --git a/app/Classes/Modules/Addresses/ControllersLogic/SetAddressToDefaultLogic.php b/app/Classes/Modules/Addresses/ControllersLogic/SetAddressToDefaultLogic.php index 1d6f81bb..f8fed1a0 100644 --- a/app/Classes/Modules/Addresses/ControllersLogic/SetAddressToDefaultLogic.php +++ b/app/Classes/Modules/Addresses/ControllersLogic/SetAddressToDefaultLogic.php @@ -2,17 +2,13 @@ namespace App\Classes\Modules\Addresses\ControllersLogic; +use App\Classes\General\Interfaces\Addressable; use App\Http\Resources\AddressResource; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\Addresses\Services\FetchesAddress; -use App\Classes\Modules\Addresses\Standards\Rules\CanUpdateAddress; use App\Classes\Modules\Addresses\Services\ResetsAddressesDefault; use App\Classes\Modules\Addresses\Services\SetsAddressToDefault; - -use App\Classes\Modules\Companies\Services\FetchesCompanyModule; - use App\Models\Address; -use ErrorException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -31,30 +27,27 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic ]; } - /** @var ResetsAddressesDefault */ - private $resetsAddressesDefault; - /** @var FetchesAddress */ private $fetchesAddress; + /** @var ResetsAddressesDefault */ + private $resetsAddressesDefault; + /** @var SetsAddressToDefault*/ private $setsAddressToDefault; - /** @var FetchesCompanyModule*/ - private $fetchesCompanyModule; /** * SetAddressToDefaultLogic constructor. - * @param ResetsAddressesDefault $resetsAddressesDefault * @param FetchesAddress $fetchesAddress + * @param ResetsAddressesDefault $resetsAddressesDefault * @param SetsAddressToDefault $setsAddressToDefault */ - public function __construct(ResetsAddressesDefault $resetsAddressesDefault, FetchesAddress $fetchesAddress, SetsAddressToDefault $setsAddressToDefault , FetchesCompanyModule $fetchesCompanyModule) + public function __construct(FetchesAddress $fetchesAddress, ResetsAddressesDefault $resetsAddressesDefault, SetsAddressToDefault $setsAddressToDefault) { - $this->resetsAddressesDefault = $resetsAddressesDefault; $this->fetchesAddress = $fetchesAddress; + $this->resetsAddressesDefault = $resetsAddressesDefault; $this->setsAddressToDefault = $setsAddressToDefault; - $this->fetchesCompanyModule = $fetchesCompanyModule; } /** @@ -69,10 +62,9 @@ class SetAddressToDefaultLogic extends AbstractControllerLogic $address = $this->fetchesAddress->execute(['id' => $request->route('id')]); - $companyModule = $this->fetchesCompanyModule->execute(['id' => $request->input('company_module_id')]); - - $this->resetsAddressesDefault->execute($companyModule); + $this->resetsAddressesDefault->execute($address->owner, $address->type); return $this->resourceResponse(new AddressResource($this->setsAddressToDefault->execute($address))); + } } diff --git a/app/Classes/Modules/Addresses/ControllersLogic/UpdateAddressLogic.php b/app/Classes/Modules/Addresses/ControllersLogic/UpdateAddressLogic.php index 805bc7ac..9d8f0600 100644 --- a/app/Classes/Modules/Addresses/ControllersLogic/UpdateAddressLogic.php +++ b/app/Classes/Modules/Addresses/ControllersLogic/UpdateAddressLogic.php @@ -10,7 +10,6 @@ use App\Classes\Modules\Addresses\Services\FetchesDistrict; use App\Classes\Modules\Addresses\Standards\Rules\CanUpdateAddress; use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject; use App\Http\Resources\AddressResource; -use ErrorException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -58,28 +57,23 @@ class UpdateAddressLogic extends AbstractControllerLogic /** * @param Request $request * @return JsonResponse - * @throws ErrorException + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse { - try { + $district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]); - $district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]); - $object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code')); - //$object = new AddressObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing')); + $object = new AddressObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'), $request->input('reference')); - $this->canUpdateAddress->passes($object); + $this->canUpdateAddress->passes($object); - $query = $this->fetchesAddress->execute(['id' => $request->route('id')]); + $address = $this->fetchesAddress->execute(['id' => $request->route('id')]); - $query = $this->updatesAddress->execute($query, $object); + $address = $this->updatesAddress->execute($address, $object); - return $this->resourceResponse(new AddressResource($query)); - - - } catch (\Exception $exception){ - throw new ErrorException($exception->getMessage(), $exception->getCode()); - } + return $this->resourceResponse(new AddressResource($address)); } diff --git a/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php b/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php index 8c164317..76c66b52 100644 --- a/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php +++ b/app/Classes/Modules/Addresses/DataTransferObjects/AddressObject.php @@ -25,6 +25,9 @@ class AddressObject implements DataTransferObject /** @var int */ private $postCode; + /** @var string|null */ + private $reference; + /** * AddressObject constructor. * @param string $streetOne @@ -33,8 +36,9 @@ class AddressObject implements DataTransferObject * @param int $stateId * @param int $districtId * @param int $postCode + * @param null|string $reference */ - public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode) + public function __construct(string $streetOne, ?string $streetTwo, int $countryId, int $stateId, int $districtId, int $postCode, ?string $reference = null) { $this->streetOne = $streetOne; $this->streetTwo = $streetTwo; @@ -42,6 +46,7 @@ class AddressObject implements DataTransferObject $this->stateId = $stateId; $this->districtId = $districtId; $this->postCode = $postCode; + $this->reference = $reference; } /** @@ -92,5 +97,13 @@ class AddressObject implements DataTransferObject return $this->postCode; } + /** + * @return null|string + */ + public function getReference(): ?string + { + return $this->reference; + } + } \ No newline at end of file diff --git a/app/Classes/Modules/Addresses/Processors/CreateOrderAddressProcessor.php b/app/Classes/Modules/Addresses/Processors/CreateOrderAddressProcessor.php index 6db43e82..1c92e410 100644 --- a/app/Classes/Modules/Addresses/Processors/CreateOrderAddressProcessor.php +++ b/app/Classes/Modules/Addresses/Processors/CreateOrderAddressProcessor.php @@ -22,7 +22,8 @@ class CreateOrderAddressProcessor /** * CreateAddressProcessor constructor. * @param CanCreateAddress $canCreateAddress - * @param CreatesAddress $CreatesAddress + * @param CreatesOrderAddress $createsOrderAddress + * @param FetchesAddress $fetchesAddress */ public function __construct(CanCreateAddress $canCreateAddress, CreatesOrderAddress $createsOrderAddress, FetchesAddress $fetchesAddress) { @@ -38,9 +39,9 @@ class CreateOrderAddressProcessor * @throws \App\Classes\Exceptions\MalformedRequestException * @throws \App\Classes\Exceptions\RequestValidationException */ - public function execute(int $address_id, Order $order): Model { + public function execute(int $address, Order $order): Model { - $address = $this->fetchesAddress->getRepository()->whereIn('id',[$address_id])->first(); + $address = $this->fetchesAddress->execute(['id' => $address_id]); // $this->canCreateAddress->passes($object); diff --git a/app/Classes/Modules/Addresses/Services/CreatesAddress.php b/app/Classes/Modules/Addresses/Services/CreatesAddress.php index 0e650f07..b6662a98 100644 --- a/app/Classes/Modules/Addresses/Services/CreatesAddress.php +++ b/app/Classes/Modules/Addresses/Services/CreatesAddress.php @@ -2,8 +2,8 @@ namespace App\Classes\Modules\Addresses\Services; -use App\Classes\General\Eloquent\AbstractUpdateRecord; use App\Classes\General\Eloquent\AbstractUpdateRelationshipRecord; +use App\Classes\General\Interfaces\Addressable; use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject; use App\Models\Address; use App\Models\CompanyModule; @@ -12,13 +12,16 @@ class CreatesAddress extends AbstractUpdateRelationshipRecord { /** - * @param Company $company + * @param Addressable $addressable * @param AddressObject $object * @return \Illuminate\Database\Eloquent\Model * @throws \App\Classes\Exceptions\MalformedRequestException */ - public function execute(CompanyModule $companyModule, AddressObject $object) { + public function execute(Addressable $addressable, AddressObject $object) { + $model = new Address(); + + $model->reference = $object->getReference(); $model->street_one = $object->getStreetOne(); $model->street_two = $object->getStreetTwo(); $model->country_id = $object->getCountryId(); @@ -26,7 +29,7 @@ class CreatesAddress extends AbstractUpdateRelationshipRecord $model->district_id = $object->getDistrictId(); $model->postcode = $object->getPostCode(); - return $this->handler($companyModule->addresses(), $model); + return $this->handler($addressable->addresses(), $model); } } \ No newline at end of file diff --git a/app/Classes/Modules/Addresses/Services/ResetsAddressesDefault.php b/app/Classes/Modules/Addresses/Services/ResetsAddressesDefault.php index 1d441326..571e96c6 100644 --- a/app/Classes/Modules/Addresses/Services/ResetsAddressesDefault.php +++ b/app/Classes/Modules/Addresses/Services/ResetsAddressesDefault.php @@ -3,6 +3,7 @@ namespace App\Classes\Modules\Addresses\Services; use App\Classes\General\Eloquent\AbstractUpdateRecord; +use App\Classes\General\Interfaces\Addressable; use App\Models\Address; use App\Models\CompanyModule; @@ -10,11 +11,12 @@ class ResetsAddressesDefault extends AbstractUpdateRecord { /** - * @param Address $address + * @param Addressable $addressable + * @param int $type * @return void */ - public function execute(CompanyModule $companyModule) + public function execute(Addressable $addressable, int $type) { - $companyModule->addresses()->update(['default' => false]); + $addressable->addresses()->where('type', $type)->update(['default' => false]); } } diff --git a/app/Classes/Modules/Addresses/Services/UpdatesAddress.php b/app/Classes/Modules/Addresses/Services/UpdatesAddress.php index 907edc73..35fad90a 100644 --- a/app/Classes/Modules/Addresses/Services/UpdatesAddress.php +++ b/app/Classes/Modules/Addresses/Services/UpdatesAddress.php @@ -17,15 +17,13 @@ class UpdatesAddress extends AbstractUpdateRecord */ public function execute(Address $model, AddressObject $object) { - //$model->company_id = $object->getCompanyId(); + $model->reference = $object->getReference(); $model->street_one = $object->getStreetOne(); $model->street_two = $object->getStreetTwo(); $model->district_id = $object->getDistrictId(); $model->state_id = $object->getStateId(); $model->postcode = $object->getPostCode(); $model->country_id = $object->getCountryId(); - //$model->default = $object->getDefault(); - //$model->billing = $object->getBilling(); return $this->handler($model); diff --git a/app/Classes/Modules/Orders/Processors/CreateOrderProcessor.php b/app/Classes/Modules/Orders/Processors/CreateOrderProcessor.php index d81bb8ff..e472a5a2 100644 --- a/app/Classes/Modules/Orders/Processors/CreateOrderProcessor.php +++ b/app/Classes/Modules/Orders/Processors/CreateOrderProcessor.php @@ -2,11 +2,15 @@ namespace App\Classes\Modules\Orders\Processors; +use App\Classes\Modules\Addresses\DataTransferObjects\AddressObject; +use App\Classes\Modules\Addresses\Services\CreatesAddress; +use App\Classes\Modules\Addresses\Services\FetchesAddress; use App\Classes\Modules\Orders\DataTransferObjects\OrderObject; use App\Classes\Modules\Orders\Services\CreatesOrder; use App\Classes\Modules\Orders\Standards\Rules\CanCreateOrder; use App\Classes\Modules\Orders\Processors\ConfirmOrderProcessor; use App\Classes\Modules\OrderSteps\Processors\CreateOrderStepsProcessor; +use App\Classes\Modules\Unity\Services\CreatesContract; use App\Classes\ValueObjects\Constants\OrderStatus; use App\Classes\ValueObjects\Constants\OrderSteps; use App\Classes\ValueObjects\Constants\OrderType; @@ -20,42 +24,69 @@ use Illuminate\Http\Request; class CreateOrderProcessor { + /** @var CanCreateOrder */ private $canCreateOrder; + /** @var CreatesOrder */ private $createsOrder; + /** @var ConfirmOrderProcessor */ private $confirmOrderProcessor; + /** @var CreateOrderStepsProcessor */ private $createOrderStepsProcessor; + /** @var CreatesContract */ private $unityCreateContract; + /** @var AssignContractEntityProcessor */ private $unityAssignContractEntity; + /** @var CreateContractEntityProcessor */ private $unityCreateContractEntity; + /** @var ActivateContractProcessor */ private $unityActivateContract; + /** @var CreateOrderRoleProcessor */ private $createOrderRoleProcessor; - private $createOrderAddressProcessor; + /** @var CreatesAddress */ + private $createAddress; - public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, CreateOrderStepsProcessor $createOrderStepsProcessor, ConfirmOrderProcessor $confirmOrderProcessor, CreateOrderRoleProcessor $createOrderRoleProcessor, CreateOrderAddressProcessor $createOrderAddressProcessor, CreateContractProcessor $unityCreateContract, CreateContractEntityProcessor $unityCreateContractEntity, AssignContractEntityProcessor $unityAssignContractEntity, ActivateContractProcessor $unityActivateContract) + /** @var FetchesAddress */ + private $fetchesAddress; + + /** + * CreateOrderProcessor constructor. + * @param CanCreateOrder $canCreateOrder + * @param CreatesOrder $createsOrder + * @param \App\Classes\Modules\Orders\Processors\ConfirmOrderProcessor $confirmOrderProcessor + * @param CreateOrderStepsProcessor $createOrderStepsProcessor + * @param CreatesContract $unityCreateContract + * @param AssignContractEntityProcessor $unityAssignContractEntity + * @param CreateContractEntityProcessor $unityCreateContractEntity + * @param ActivateContractProcessor $unityActivateContract + * @param \App\Classes\Modules\Orders\Processors\CreateOrderRoleProcessor $createOrderRoleProcessor + * @param CreatesAddress $createAddress + * @param FetchesAddress $fetchesAddress + */ + public function __construct(CanCreateOrder $canCreateOrder, CreatesOrder $createsOrder, \App\Classes\Modules\Orders\Processors\ConfirmOrderProcessor $confirmOrderProcessor, CreateOrderStepsProcessor $createOrderStepsProcessor, CreatesContract $unityCreateContract, AssignContractEntityProcessor $unityAssignContractEntity, CreateContractEntityProcessor $unityCreateContractEntity, ActivateContractProcessor $unityActivateContract, \App\Classes\Modules\Orders\Processors\CreateOrderRoleProcessor $createOrderRoleProcessor, CreatesAddress $createAddress, FetchesAddress $fetchesAddress) { $this->canCreateOrder = $canCreateOrder; - $this->createsOrder = $createsOrder; - $this->createOrderRoleProcessor = $createOrderRoleProcessor; $this->confirmOrderProcessor = $confirmOrderProcessor; $this->createOrderStepsProcessor = $createOrderStepsProcessor; - $this->createOrderAddressProcessor = $createOrderAddressProcessor; - $this->unityCreateContract = $unityCreateContract; - $this->unityActivateContract = $unityActivateContract; $this->unityAssignContractEntity = $unityAssignContractEntity; $this->unityCreateContractEntity = $unityCreateContractEntity; + $this->unityActivateContract = $unityActivateContract; + $this->createOrderRoleProcessor = $createOrderRoleProcessor; + $this->createAddress = $createAddress; + $this->fetchesAddress = $fetchesAddress; } + public function execute(Request $request){ $reference_no = rand(1000000, 9999999); @@ -69,12 +100,16 @@ class CreateOrderProcessor $activated = $this->unityActivateContract->execute($contract_reference_no); //Create Order on Shipping Platform - $order_object = new OrderObject($request->get('company_module_id'), $contract_reference_no, '', OrderType::SHARED_CONTAINER, OrderStatus::PROCESSING, OrderSteps::PROCESSING, 0, $request->get('address_id'), $request->get('warehouse_id')); + $order_object = new OrderObject($request->get('company_module_id'), $reference_no, $contract_reference_no, OrderType::SHARED_CONTAINER, OrderStatus::PROCESSING, OrderSteps::PROCESSING, 0, $request->get('address_id'), $request->get('warehouse_id')); $this->canCreateOrder->passes($order_object); $order = $this->createsOrder->execute($order_object); + $address = $this->fetchesAddress->execute(['id' => $order_object->getAddressId()]); + + $addressObject = new AddressObject($address->street_one, $address->street_two, $address->country_id, $address->state_id, $address->district_id, $address->postcode,$address->reference); + //Add address (polymorphic) - $this->createOrderAddressProcessor->execute($request->get('address_id'), $order); + $this->createAddress->execute($order, $addressObject); //Add order roles - Allow entity to process this order //This processor calls Unity to create Contract Entity ID diff --git a/app/Classes/ValueObjects/Constants/AddressType.php b/app/Classes/ValueObjects/Constants/AddressType.php new file mode 100644 index 00000000..4fdc3a29 --- /dev/null +++ b/app/Classes/ValueObjects/Constants/AddressType.php @@ -0,0 +1,11 @@ + $this->id, + 'reference' => $this->reference, 'street_one' => $this->street_one, 'street_two' => $this->street_two, 'district' => $this->district, diff --git a/app/Models/CompanyModule.php b/app/Models/CompanyModule.php index ce6ffc90..e2ba6634 100644 --- a/app/Models/CompanyModule.php +++ b/app/Models/CompanyModule.php @@ -2,6 +2,8 @@ namespace App\Models; +use App\Classes\General\Interfaces\Addressable; +use App\Classes\General\Interfaces\Documentable; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -18,7 +20,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property integer type * @property integer status */ -class CompanyModule extends AbstractModel +class CompanyModule extends AbstractModel implements Addressable, Documentable { use SoftDeletes; @@ -66,66 +68,28 @@ class CompanyModule extends AbstractModel return $this->HasMany(Order::class, 'company_module_id'); } + /** + * @return belongsToMany + */ + public function segments(): belongsToMany + { + return $this->belongsToMany(Segment::class, (new SegmentCompany())->getTable(), 'company_id', 'segment_id'); + } - // /** - // * @return HasMany - // */ - // public function addresses(): HasMany - // { - // return $this->HasMany(Address::class, 'company_id'); - // } + /** + * @return MorphMany + */ + public function documents(): morphMany + { + return $this->morphMany(Document::class, 'owner'); + } - // /** - // * @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'))); - // }); - // } + /** + * @return HasMany + */ + public function banks(): HasMany + { + return $this->HasMany(Bank::class, 'company_id'); + } } diff --git a/app/Models/Order.php b/app/Models/Order.php index 5b07a887..aecf7f4e 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -2,13 +2,14 @@ namespace App\Models; +use App\Classes\General\Interfaces\Addressable; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\MorphMany; -class Order extends AbstractModel +class Order extends AbstractModel implements Addressable { use SoftDeletes; diff --git a/database/migrations/2021_06_21_232944_create_addresses_table.php b/database/migrations/2021_06_21_232944_create_addresses_table.php index 30c9fc37..b75b4777 100644 --- a/database/migrations/2021_06_21_232944_create_addresses_table.php +++ b/database/migrations/2021_06_21_232944_create_addresses_table.php @@ -1,5 +1,6 @@ id(); $table->morphs('owner'); - $table->string('street_one', '45'); - $table->string('street_two', '45')->nullable(); + $table->string('reference')->nullable(); + $table->string('street_one'); + $table->string('street_two')->nullable(); $table->foreignId('district_id')->constrained(); $table->foreignId('state_id')->constrained(); $table->foreignId('country_id')->constrained(); $table->string('postcode', '45'); + $table->integer('type')->default(AddressType::DELIVERY); $table->integer('default')->default(false); $table->softDeletes(); $table->timestamps(); diff --git a/resources/assets/images/guangzhou-map.png b/resources/assets/images/guangzhou-map.png new file mode 100644 index 00000000..c82f61ba Binary files /dev/null and b/resources/assets/images/guangzhou-map.png differ diff --git a/resources/assets/images/maintenance.png b/resources/assets/images/maintenance.png new file mode 100644 index 00000000..60fe77a2 Binary files /dev/null and b/resources/assets/images/maintenance.png differ diff --git a/resources/assets/images/not-found-illustration.png b/resources/assets/images/not-found-illustration.png new file mode 100644 index 00000000..4769bcd7 Binary files /dev/null and b/resources/assets/images/not-found-illustration.png differ diff --git a/resources/assets/images/package.svg b/resources/assets/images/package.svg new file mode 100644 index 00000000..1c4f6c7b --- /dev/null +++ b/resources/assets/images/package.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/assets/images/package_hands.svg b/resources/assets/images/package_hands.svg new file mode 100644 index 00000000..59c39453 --- /dev/null +++ b/resources/assets/images/package_hands.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/assets/images/qr-box.svg b/resources/assets/images/qr-box.svg new file mode 100644 index 00000000..f74a7839 --- /dev/null +++ b/resources/assets/images/qr-box.svg @@ -0,0 +1,378 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/assets/images/qr.svg b/resources/assets/images/qr.svg new file mode 100644 index 00000000..13888433 --- /dev/null +++ b/resources/assets/images/qr.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/assets/images/yiwu-map.png b/resources/assets/images/yiwu-map.png new file mode 100644 index 00000000..d6d3cd72 Binary files /dev/null and b/resources/assets/images/yiwu-map.png differ diff --git a/resources/assets/sass/modules/_layout.scss b/resources/assets/sass/modules/_layout.scss index 4430826f..ea78b6bb 100644 --- a/resources/assets/sass/modules/_layout.scss +++ b/resources/assets/sass/modules/_layout.scss @@ -2179,3 +2179,49 @@ select2-dropdown, background : radial-gradient(#fff 1px, transparent 2px); background-size : 12px 12px; } + +.peelable-corner { + cursor: pointer; + &::before { + content: ''; + display: block; + width: 30px; + height: 30px; + position: absolute; + left: 0px; + top: 0px; + background: $color-white; + -webkit-transition: 0.5s; + transition: 0.5s; + box-shadow: 0 0.5rem 0.5rem rgba(0,0,0,.15)!important; + } + &::after { + content: ''; + display: block; + width: 30px*1.4; + height: 30px*1.4; + position: absolute; + left: 30px*-0.7; + top: 30px*-0.7; + background: $color-master-lightest; + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -o-transform: rotate(45deg); + -ms-transform: rotate(45deg); + transform: rotate(45deg); + -webkit-transition: 0.5s; + transition: 0.5s; + } + &:hover { + &::before { + width: 50px*1.3; + height: 50px*1.3; + } + &::after { + width: 50px*1.8; + height: 50px*1.8; + top: 50px*-0.9; + left: 50px*-0.9; + } + } +} diff --git a/resources/assets/vue/components/address/forms/AddressFormComponent.vue b/resources/assets/vue/components/address/forms/AddressFormComponent.vue deleted file mode 100644 index 6bd8840d..00000000 --- a/resources/assets/vue/components/address/forms/AddressFormComponent.vue +++ /dev/null @@ -1,128 +0,0 @@ - - diff --git a/resources/assets/vue/components/addresses/elements/SelectAddressComponent.vue b/resources/assets/vue/components/addresses/elements/SelectAddressComponent.vue new file mode 100644 index 00000000..587f2394 --- /dev/null +++ b/resources/assets/vue/components/addresses/elements/SelectAddressComponent.vue @@ -0,0 +1,78 @@ + + + \ No newline at end of file diff --git a/resources/assets/vue/components/addresses/forms/AddressFormComponent.vue b/resources/assets/vue/components/addresses/forms/AddressFormComponent.vue new file mode 100644 index 00000000..c835a73a --- /dev/null +++ b/resources/assets/vue/components/addresses/forms/AddressFormComponent.vue @@ -0,0 +1,101 @@ + + diff --git a/resources/assets/vue/components/addresses/forms/DeleteAddressFormComponent.vue b/resources/assets/vue/components/addresses/forms/DeleteAddressFormComponent.vue new file mode 100644 index 00000000..9fbc94a1 --- /dev/null +++ b/resources/assets/vue/components/addresses/forms/DeleteAddressFormComponent.vue @@ -0,0 +1,33 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue b/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue deleted file mode 100644 index 6d8979aa..00000000 --- a/resources/assets/vue/components/companies/sections/customerDashboardSectionComponent.vue +++ /dev/null @@ -1,21 +0,0 @@ - - \ No newline at end of file diff --git a/resources/assets/vue/components/general/elements/ListComponent.vue b/resources/assets/vue/components/general/elements/ListComponent.vue index 50d2fa19..2b6d74bd 100644 --- a/resources/assets/vue/components/general/elements/ListComponent.vue +++ b/resources/assets/vue/components/general/elements/ListComponent.vue @@ -1,5 +1,5 @@