Updates for elastic search

This commit is contained in:
David Bomba 2025-03-11 15:42:45 +11:00
parent 66491dadc9
commit c8407c417b
11 changed files with 61 additions and 80 deletions

View File

@ -249,10 +249,10 @@ class Client extends BaseModel implements HasLocalePreference
} }
return [ return [
'id' => $this->id, 'id' => $this->company->db.":".$this->id,
'name' => $name, 'name' => $name,
'is_deleted' => $this->is_deleted, 'is_deleted' => $this->is_deleted,
'hashed_id' => $this->company->db.":".$this->hashed_id, 'hashed_id' => $this->hashed_id,
'number' => $this->number, 'number' => $this->number,
'id_number' => $this->id_number, 'id_number' => $this->id_number,
'vat_number' => $this->vat_number, 'vat_number' => $this->vat_number,
@ -282,12 +282,7 @@ class Client extends BaseModel implements HasLocalePreference
public function getScoutKey() public function getScoutKey()
{ {
return $this->company->db.":".$this->hashed_id; return $this->company->db.":".$this->id;
}
public function getScoutKeyName()
{
return 'hashed_id';
} }
public function getEntityType() public function getEntityType()

View File

@ -171,9 +171,9 @@ class ClientContact extends Authenticatable implements HasLocalePreference
public function toSearchableArray() public function toSearchableArray()
{ {
return [ return [
'id' => $this->id, 'id' => $this->company->db.":".$this->id,
'name' => $this->present()->search_display(), 'name' => $this->present()->search_display(),
'hashed_id' => $this->company->db.":".$this->hashed_id, 'hashed_id' => $this->hashed_id,
'email' => $this->email, 'email' => $this->email,
'first_name' => $this->first_name, 'first_name' => $this->first_name,
'last_name' => $this->last_name, 'last_name' => $this->last_name,
@ -189,12 +189,7 @@ class ClientContact extends Authenticatable implements HasLocalePreference
public function getScoutKey() public function getScoutKey()
{ {
return $this->company->db.":".$this->hashed_id; return $this->company->db.":".$this->id;
}
public function getScoutKeyName(): mixed
{
return 'hashed_id';
} }
/* /*

View File

@ -205,9 +205,9 @@ class Credit extends BaseModel
App::setLocale($locale); App::setLocale($locale);
return [ 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), '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, 'number' => $this->number,
'is_deleted' => $this->is_deleted, 'is_deleted' => $this->is_deleted,
'amount' => (float) $this->amount, 'amount' => (float) $this->amount,
@ -225,12 +225,7 @@ class Credit extends BaseModel
public function getScoutKey() public function getScoutKey()
{ {
return $this->company->db.":".$this->hashed_id; return $this->company->db.":".$this->id;
}
public function getScoutKeyName(): mixed
{
return 'hashed_id';
} }
public function getEntityType() public function getEntityType()

View File

@ -172,9 +172,9 @@ class Expense extends BaseModel
App::setLocale($locale); App::setLocale($locale);
return [ 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), '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, 'number' => $this->number,
'is_deleted' => $this->is_deleted, 'is_deleted' => $this->is_deleted,
'amount' => (float) $this->amount, 'amount' => (float) $this->amount,
@ -189,14 +189,10 @@ class Expense extends BaseModel
public function getScoutKey() public function getScoutKey()
{ {
return $this->company->db.":".$this->hashed_id; return $this->company->db.":".$this->id;
}
public function getScoutKeyName(): mixed
{
return 'hashed_id';
} }
public function getEntityType() public function getEntityType()
{ {
return self::class; return self::class;

View File

@ -249,9 +249,9 @@ class Invoice extends BaseModel
App::setLocale($locale); App::setLocale($locale);
return [ 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), '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, 'number' => $this->number,
'is_deleted' => $this->is_deleted, 'is_deleted' => $this->is_deleted,
'amount' => (float) $this->amount, 'amount' => (float) $this->amount,
@ -269,12 +269,7 @@ class Invoice extends BaseModel
public function getScoutKey() public function getScoutKey()
{ {
return $this->company->db.":".$this->hashed_id; return $this->company->db.":".$this->id;
}
public function getScoutKeyName(): mixed
{
return 'hashed_id';
} }
public function getEntityType() public function getEntityType()

View File

@ -209,9 +209,9 @@ class PurchaseOrder extends BaseModel
App::setLocale($locale); App::setLocale($locale);
return [ 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), '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, 'number' => $this->number,
'is_deleted' => $this->is_deleted, 'is_deleted' => $this->is_deleted,
'amount' => (float) $this->amount, 'amount' => (float) $this->amount,
@ -229,14 +229,10 @@ class PurchaseOrder extends BaseModel
public function getScoutKey() public function getScoutKey()
{ {
return $this->company->db.":".$this->hashed_id; return $this->company->db.":".$this->id;
}
public function getScoutKeyName(): mixed
{
return 'hashed_id';
} }
public static function stringStatus(int $status) public static function stringStatus(int $status)
{ {
switch ($status) { switch ($status) {

View File

@ -199,9 +199,9 @@ class Quote extends BaseModel
App::setLocale($locale); App::setLocale($locale);
return [ 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), '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, 'number' => $this->number,
'is_deleted' => $this->is_deleted, 'is_deleted' => $this->is_deleted,
'amount' => (float) $this->amount, 'amount' => (float) $this->amount,
@ -219,12 +219,7 @@ class Quote extends BaseModel
public function getScoutKey() public function getScoutKey()
{ {
return $this->company->db.":".$this->hashed_id; return $this->company->db.":".$this->id;
}
public function getScoutKeyName(): mixed
{
return 'hashed_id';
} }
public function getEntityType() public function getEntityType()

View File

@ -273,9 +273,9 @@ class RecurringInvoice extends BaseModel
App::setLocale($locale); App::setLocale($locale);
return [ 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), '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, 'number' => $this->number,
'is_deleted' => $this->is_deleted, 'is_deleted' => $this->is_deleted,
'amount' => (float) $this->amount, 'amount' => (float) $this->amount,
@ -293,14 +293,10 @@ class RecurringInvoice extends BaseModel
public function getScoutKey() public function getScoutKey()
{ {
return $this->company->db.":".$this->hashed_id; return $this->company->db.":".$this->id;
}
public function getScoutKeyName(): mixed
{
return 'hashed_id';
} }
public function getEntityType() public function getEntityType()
{ {
return self::class; return self::class;

View File

@ -154,10 +154,10 @@ class Vendor extends BaseModel
} }
return [ return [
'id' => $this->id, 'id' => $this->company->db.":".$this->id,
'name' => $name, 'name' => $name,
'is_deleted' => $this->is_deleted, 'is_deleted' => $this->is_deleted,
'hashed_id' => $this->company->db.":".$this->hashed_id, 'hashed_id' => $this->hashed_id,
'number' => $this->number, 'number' => $this->number,
'id_number' => $this->id_number, 'id_number' => $this->id_number,
'vat_number' => $this->vat_number, 'vat_number' => $this->vat_number,
@ -180,12 +180,7 @@ class Vendor extends BaseModel
public function getScoutKey() public function getScoutKey()
{ {
return $this->company->db.":".$this->hashed_id; return $this->company->db.":".$this->id;
}
public function getScoutKeyName(): mixed
{
return 'hashed_id';
} }
protected $presenter = VendorPresenter::class; protected $presenter = VendorPresenter::class;

View File

@ -128,9 +128,9 @@ class VendorContact extends Authenticatable implements HasLocalePreference
public function toSearchableArray() public function toSearchableArray()
{ {
return [ return [
'id' => $this->id, 'id' => $this->company->db.":".$this->id,
'name' => $this->present()->search_display(), 'name' => $this->present()->search_display(),
'hashed_id' => $this->company->db.":".$this->hashed_id, 'hashed_id' => $this->hashed_id,
'email' => $this->email, 'email' => $this->email,
'first_name' => $this->first_name, 'first_name' => $this->first_name,
'last_name' => $this->last_name, 'last_name' => $this->last_name,
@ -146,12 +146,7 @@ class VendorContact extends Authenticatable implements HasLocalePreference
public function getScoutKey() public function getScoutKey()
{ {
return $this->company->db.":".$this->hashed_id; return $this->company->db.":".$this->id;
}
public function getScoutKeyName(): mixed
{
return 'hashed_id';
} }
public function avatar() public function avatar()

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
if($g = \App\Models\Gateway::find(65))
{
$g->site_url = 'https://help.blockonomics.co/a/solutions/articles/33000291849';
$g->save();
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};