From c8407c417b9cd27074d15fa6db53f0d1af95cfa9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 11 Mar 2025 15:42:45 +1100 Subject: [PATCH] Updates for elastic search --- app/Models/Client.php | 11 ++------ app/Models/ClientContact.php | 11 ++------ app/Models/Credit.php | 11 ++------ app/Models/Expense.php | 12 +++----- app/Models/Invoice.php | 11 ++------ app/Models/PurchaseOrder.php | 12 +++----- app/Models/Quote.php | 11 ++------ app/Models/RecurringInvoice.php | 12 +++----- app/Models/Vendor.php | 11 ++------ app/Models/VendorContact.php | 11 ++------ ...11_044138_update_blockonomics_help_url.php | 28 +++++++++++++++++++ 11 files changed, 61 insertions(+), 80 deletions(-) create mode 100644 database/migrations/2025_03_11_044138_update_blockonomics_help_url.php diff --git a/app/Models/Client.php b/app/Models/Client.php index 1dbc437b27..5f8ac53f2a 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -249,10 +249,10 @@ class Client extends BaseModel implements HasLocalePreference } return [ - 'id' => $this->id, + 'id' => $this->company->db.":".$this->id, 'name' => $name, 'is_deleted' => $this->is_deleted, - 'hashed_id' => $this->company->db.":".$this->hashed_id, + 'hashed_id' => $this->hashed_id, 'number' => $this->number, 'id_number' => $this->id_number, 'vat_number' => $this->vat_number, @@ -282,12 +282,7 @@ class Client extends BaseModel implements HasLocalePreference public function getScoutKey() { - return $this->company->db.":".$this->hashed_id; - } - - public function getScoutKeyName() - { - return 'hashed_id'; + return $this->company->db.":".$this->id; } public function getEntityType() diff --git a/app/Models/ClientContact.php b/app/Models/ClientContact.php index ea3dfdd4e9..a4e34521cd 100644 --- a/app/Models/ClientContact.php +++ b/app/Models/ClientContact.php @@ -171,9 +171,9 @@ class ClientContact extends Authenticatable implements HasLocalePreference public function toSearchableArray() { return [ - 'id' => $this->id, + 'id' => $this->company->db.":".$this->id, 'name' => $this->present()->search_display(), - 'hashed_id' => $this->company->db.":".$this->hashed_id, + 'hashed_id' => $this->hashed_id, 'email' => $this->email, 'first_name' => $this->first_name, 'last_name' => $this->last_name, @@ -189,12 +189,7 @@ class ClientContact extends Authenticatable implements HasLocalePreference public function getScoutKey() { - return $this->company->db.":".$this->hashed_id; - } - - public function getScoutKeyName(): mixed - { - return 'hashed_id'; + return $this->company->db.":".$this->id; } /* diff --git a/app/Models/Credit.php b/app/Models/Credit.php index 3b5098c630..eb878cc149 100644 --- a/app/Models/Credit.php +++ b/app/Models/Credit.php @@ -205,9 +205,9 @@ class Credit extends BaseModel App::setLocale($locale); return [ - 'id' => $this->id, + 'id' => $this->company->db.":".$this->id, 'name' => ctrans('texts.credit') . " " . $this->number . " | " . $this->client->present()->name() . ' | ' . Number::formatMoney($this->amount, $this->company) . ' | ' . $this->translateDate($this->date, $this->company->date_format(), $locale), - 'hashed_id' => $this->company->db.":".$this->hashed_id, + 'hashed_id' => $this->hashed_id, 'number' => $this->number, 'is_deleted' => $this->is_deleted, 'amount' => (float) $this->amount, @@ -225,12 +225,7 @@ class Credit extends BaseModel public function getScoutKey() { - return $this->company->db.":".$this->hashed_id; - } - - public function getScoutKeyName(): mixed - { - return 'hashed_id'; + return $this->company->db.":".$this->id; } public function getEntityType() diff --git a/app/Models/Expense.php b/app/Models/Expense.php index 268b27576d..824a2bf792 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -172,9 +172,9 @@ class Expense extends BaseModel App::setLocale($locale); return [ - 'id' => $this->id, + 'id' => $this->company->db.":".$this->id, 'name' => ctrans('texts.expense') . " " . ($this->number ?? '') . ' | ' . Number::formatMoney($this->amount, $this->company) . ' | ' . $this->translateDate($this->date, $this->company->date_format(), $locale), - 'hashed_id' => $this->company->db.":".$this->hashed_id, + 'hashed_id' => $this->hashed_id, 'number' => $this->number, 'is_deleted' => $this->is_deleted, 'amount' => (float) $this->amount, @@ -189,14 +189,10 @@ class Expense extends BaseModel public function getScoutKey() { - return $this->company->db.":".$this->hashed_id; - } - - public function getScoutKeyName(): mixed - { - return 'hashed_id'; + return $this->company->db.":".$this->id; } + public function getEntityType() { return self::class; diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 75cb5ed088..470bb566f2 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -249,9 +249,9 @@ class Invoice extends BaseModel App::setLocale($locale); return [ - 'id' => $this->id, + 'id' => $this->company->db.":".$this->id, 'name' => ctrans('texts.invoice') . " " . $this->number . " | " . $this->client->present()->name() . ' | ' . Number::formatMoney($this->amount, $this->company) . ' | ' . $this->translateDate($this->date, $this->company->date_format(), $locale), - 'hashed_id' => $this->company->db.":".$this->hashed_id, + 'hashed_id' => $this->hashed_id, 'number' => $this->number, 'is_deleted' => $this->is_deleted, 'amount' => (float) $this->amount, @@ -269,12 +269,7 @@ class Invoice extends BaseModel public function getScoutKey() { - return $this->company->db.":".$this->hashed_id; - } - - public function getScoutKeyName(): mixed - { - return 'hashed_id'; + return $this->company->db.":".$this->id; } public function getEntityType() diff --git a/app/Models/PurchaseOrder.php b/app/Models/PurchaseOrder.php index 7f4dc371f6..dc4c7000d4 100644 --- a/app/Models/PurchaseOrder.php +++ b/app/Models/PurchaseOrder.php @@ -209,9 +209,9 @@ class PurchaseOrder extends BaseModel App::setLocale($locale); return [ - 'id' => $this->id, + 'id' => $this->company->db.":".$this->id, 'name' => ctrans('texts.purchase_order') . " " . $this->number . " | " . $this->vendor->present()->name() . ' | ' . Number::formatMoney($this->amount, $this->company) . ' | ' . $this->translateDate($this->date, $this->company->date_format(), $locale), - 'hashed_id' => $this->company->db.":".$this->hashed_id, + 'hashed_id' => $this->hashed_id, 'number' => $this->number, 'is_deleted' => $this->is_deleted, 'amount' => (float) $this->amount, @@ -229,14 +229,10 @@ class PurchaseOrder extends BaseModel public function getScoutKey() { - return $this->company->db.":".$this->hashed_id; - } - - public function getScoutKeyName(): mixed - { - return 'hashed_id'; + return $this->company->db.":".$this->id; } + public static function stringStatus(int $status) { switch ($status) { diff --git a/app/Models/Quote.php b/app/Models/Quote.php index df905e7070..61126f769e 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -199,9 +199,9 @@ class Quote extends BaseModel App::setLocale($locale); return [ - 'id' => $this->id, + 'id' => $this->company->db.":".$this->id, 'name' => ctrans('texts.quote') . " " . ($this->number ?? '') . " | " . $this->client->present()->name() . ' | ' . Number::formatMoney($this->amount, $this->company) . ' | ' . $this->translateDate($this->date, $this->company->date_format(), $locale), - 'hashed_id' => $this->company->db.":".$this->hashed_id, + 'hashed_id' => $this->hashed_id, 'number' => $this->number, 'is_deleted' => $this->is_deleted, 'amount' => (float) $this->amount, @@ -219,12 +219,7 @@ class Quote extends BaseModel public function getScoutKey() { - return $this->company->db.":".$this->hashed_id; - } - - public function getScoutKeyName(): mixed - { - return 'hashed_id'; + return $this->company->db.":".$this->id; } public function getEntityType() diff --git a/app/Models/RecurringInvoice.php b/app/Models/RecurringInvoice.php index 2e2fd1ec5d..3745cdb4ee 100644 --- a/app/Models/RecurringInvoice.php +++ b/app/Models/RecurringInvoice.php @@ -273,9 +273,9 @@ class RecurringInvoice extends BaseModel App::setLocale($locale); return [ - 'id' => $this->id, + 'id' => $this->company->db.":".$this->id, 'name' => ctrans('texts.recurring_invoice') . " " . $this->number . " | " . $this->client->present()->name() . ' | ' . Number::formatMoney($this->amount, $this->company) . ' | ' . $this->translateDate($this->date, $this->company->date_format(), $locale), - 'hashed_id' => $this->company->db.":".$this->hashed_id, + 'hashed_id' => $this->hashed_id, 'number' => $this->number, 'is_deleted' => $this->is_deleted, 'amount' => (float) $this->amount, @@ -293,14 +293,10 @@ class RecurringInvoice extends BaseModel public function getScoutKey() { - return $this->company->db.":".$this->hashed_id; - } - - public function getScoutKeyName(): mixed - { - return 'hashed_id'; + return $this->company->db.":".$this->id; } + public function getEntityType() { return self::class; diff --git a/app/Models/Vendor.php b/app/Models/Vendor.php index d2ea1d4538..5726239f58 100644 --- a/app/Models/Vendor.php +++ b/app/Models/Vendor.php @@ -154,10 +154,10 @@ class Vendor extends BaseModel } return [ - 'id' => $this->id, + 'id' => $this->company->db.":".$this->id, 'name' => $name, 'is_deleted' => $this->is_deleted, - 'hashed_id' => $this->company->db.":".$this->hashed_id, + 'hashed_id' => $this->hashed_id, 'number' => $this->number, 'id_number' => $this->id_number, 'vat_number' => $this->vat_number, @@ -180,12 +180,7 @@ class Vendor extends BaseModel public function getScoutKey() { - return $this->company->db.":".$this->hashed_id; - } - - public function getScoutKeyName(): mixed - { - return 'hashed_id'; + return $this->company->db.":".$this->id; } protected $presenter = VendorPresenter::class; diff --git a/app/Models/VendorContact.php b/app/Models/VendorContact.php index f09d3acbea..6a5b86698d 100644 --- a/app/Models/VendorContact.php +++ b/app/Models/VendorContact.php @@ -128,9 +128,9 @@ class VendorContact extends Authenticatable implements HasLocalePreference public function toSearchableArray() { return [ - 'id' => $this->id, + 'id' => $this->company->db.":".$this->id, 'name' => $this->present()->search_display(), - 'hashed_id' => $this->company->db.":".$this->hashed_id, + 'hashed_id' => $this->hashed_id, 'email' => $this->email, 'first_name' => $this->first_name, 'last_name' => $this->last_name, @@ -146,12 +146,7 @@ class VendorContact extends Authenticatable implements HasLocalePreference public function getScoutKey() { - return $this->company->db.":".$this->hashed_id; - } - - public function getScoutKeyName(): mixed - { - return 'hashed_id'; + return $this->company->db.":".$this->id; } public function avatar() diff --git a/database/migrations/2025_03_11_044138_update_blockonomics_help_url.php b/database/migrations/2025_03_11_044138_update_blockonomics_help_url.php new file mode 100644 index 0000000000..80a7300fc7 --- /dev/null +++ b/database/migrations/2025_03_11_044138_update_blockonomics_help_url.php @@ -0,0 +1,28 @@ +site_url = 'https://help.blockonomics.co/a/solutions/articles/33000291849'; + $g->save(); + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // + } +};