diff --git a/app/Classes/General/Eloquent/Filters/CompanySegmentsIn.php b/app/Classes/General/Eloquent/Filters/CompanySegmentsIn.php new file mode 100644 index 00000000..dd86d514 --- /dev/null +++ b/app/Classes/General/Eloquent/Filters/CompanySegmentsIn.php @@ -0,0 +1,24 @@ +whereHas('companyModules', function ($module) use ($value) { + $module->whereHas('connections', function ($connection) use ($value) { + $connection->whereHas('connectionSegments', function ($segment) use ($value) { + $segment->whereIn('segment_id', $value); + }); + }); + }); + } +} diff --git a/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php b/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php index e832b854..614e882d 100644 --- a/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php +++ b/app/Classes/Modules/Companies/ControllersLogic/AssignCompanyConnectionToConnectionSegmentLogic.php @@ -69,7 +69,7 @@ class AssignCompanyConnectionToConnectionSegmentLogic extends AbstractController $this->assignCompanyConnectionToConnectionSegmentProcessor->execute($companyConnection, $request->input('segment_id')); - if ($request->input('segment_id') == 11) { + if ($request->input('segment_id') != 12) { $contactObject = new ContactObject('Whatsapp: ' . $request->input('name'), $request->input('phone'), null, null); $this->createContactProcessor->execute($contactObject, $company); } diff --git a/app/Http/Resources/CompanyResource.php b/app/Http/Resources/CompanyResource.php index d969ac0d..27a04166 100644 --- a/app/Http/Resources/CompanyResource.php +++ b/app/Http/Resources/CompanyResource.php @@ -40,7 +40,8 @@ class CompanyResource extends JsonResource 'last_order' => $companyModule->type === 7 ? new DeliveryOrderResource($companyModule->orders()->orderBy('id', 'DESC')->first()) : new OrderResource($companyModule->orders()->orderBy('id', 'DESC')->first()), 'order_count' => $companyModule->orders()->count(), 'identification' => new DocumentResource($this->documents->whereIn('document_type', DocumentType::IDENTIFICATION_DOCUMENTS)->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])->first()), - 'created_at' => $this->created_at->format('d-m-Y') + 'created_at' => $this->created_at->format('d-m-Y'), + 'whatsapp' => new ContactResource($this->contacts()->where('reference', 'LIKE', '%Whatsapp%')->orderBy('created_at', 'DESC')->first()) ]; diff --git a/app/Http/Resources/SegmentResource.php b/app/Http/Resources/SegmentResource.php index 2ec22145..85c61f61 100644 --- a/app/Http/Resources/SegmentResource.php +++ b/app/Http/Resources/SegmentResource.php @@ -18,7 +18,7 @@ class SegmentResource extends JsonResource $constant = $this->constants->where('reference', SegmentConstants::CUSTOM_PRICE)->first(); return [ 'id' => $this->id, - 'name' => $this->name, + 'name' => ucwords(str_replace('_', ' ', $this->name)), 'price' => $constant ? $constant->value[0] : 0 ]; } diff --git a/app/Models/CompanyConnection.php b/app/Models/CompanyConnection.php index b382e237..894cdafc 100644 --- a/app/Models/CompanyConnection.php +++ b/app/Models/CompanyConnection.php @@ -69,4 +69,12 @@ class CompanyConnection extends AbstractModel return $this->belongsToMany(Segment::class, (new ConnectionSegment())->getTable(), 'company_connection_id', 'segment_id'); } + /** + * @return belongsToMany + */ + public function connectionSegments(): HasMany + { + return $this->hasMany(ConnectionSegment::class, 'company_connection_id'); + } + } diff --git a/resources/assets/vue/components/companies/elements/CompanyComponent.vue b/resources/assets/vue/components/companies/elements/CompanyComponent.vue index 293bca54..2353102d 100644 --- a/resources/assets/vue/components/companies/elements/CompanyComponent.vue +++ b/resources/assets/vue/components/companies/elements/CompanyComponent.vue @@ -10,6 +10,10 @@
{{this.item.name}}
CIEF/{{this.item.company_module.marking}}
+
+
Whatsapp:
+
{{ this.item.whatsapp.reference.replace('Whatsapp:', '') }}: {{ this.item.whatsapp.phone }}
+
Orders
{{this.item.order_count}}
diff --git a/resources/assets/vue/components/companies/elements/FulfilmentConfirmationFormComponent.vue b/resources/assets/vue/components/companies/elements/FulfilmentConfirmationFormComponent.vue deleted file mode 100644 index 70222929..00000000 --- a/resources/assets/vue/components/companies/elements/FulfilmentConfirmationFormComponent.vue +++ /dev/null @@ -1,38 +0,0 @@ - - diff --git a/resources/assets/vue/components/companies/elements/FulfilmentLaterFormComponent.vue b/resources/assets/vue/components/companies/elements/FulfilmentInterestedFormComponent.vue similarity index 57% rename from resources/assets/vue/components/companies/elements/FulfilmentLaterFormComponent.vue rename to resources/assets/vue/components/companies/elements/FulfilmentInterestedFormComponent.vue index 2d803989..28492048 100644 --- a/resources/assets/vue/components/companies/elements/FulfilmentLaterFormComponent.vue +++ b/resources/assets/vue/components/companies/elements/FulfilmentInterestedFormComponent.vue @@ -1,6 +1,6 @@