add new search engine
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Models\Shop;
|
|||||||
|
|
||||||
use App\Models\Botanic\Specie;
|
use App\Models\Botanic\Specie;
|
||||||
use App\Models\Botanic\Variety;
|
use App\Models\Botanic\Variety;
|
||||||
|
use App\Repositories\Shop\Articles;
|
||||||
use App\Traits\Model\HasComments;
|
use App\Traits\Model\HasComments;
|
||||||
use App\Traits\Model\Imageable;
|
use App\Traits\Model\Imageable;
|
||||||
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
use Fico7489\Laravel\EloquentJoin\Traits\EloquentJoin;
|
||||||
@@ -15,6 +16,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|||||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Kirschbaum\PowerJoins\PowerJoins;
|
use Kirschbaum\PowerJoins\PowerJoins;
|
||||||
|
use Laravel\Scout\Searchable;
|
||||||
use Rinvex\Categories\Traits\Categorizable;
|
use Rinvex\Categories\Traits\Categorizable;
|
||||||
use Rinvex\Tags\Traits\Taggable;
|
use Rinvex\Tags\Traits\Taggable;
|
||||||
use Spatie\MediaLibrary\HasMedia;
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
@@ -31,6 +33,7 @@ class Article extends Model implements HasMedia
|
|||||||
use Imageable;
|
use Imageable;
|
||||||
use Powerjoins;
|
use Powerjoins;
|
||||||
use RevisionableTrait;
|
use RevisionableTrait;
|
||||||
|
use Searchable;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
use Taggable;
|
use Taggable;
|
||||||
use UserStamps;
|
use UserStamps;
|
||||||
@@ -192,7 +195,31 @@ class Article extends Model implements HasMedia
|
|||||||
public function scopeWithAvailableOffers($query, $saleChannelId = false)
|
public function scopeWithAvailableOffers($query, $saleChannelId = false)
|
||||||
{
|
{
|
||||||
return $query->whereHas('offers', function ($query) use ($saleChannelId) {
|
return $query->whereHas('offers', function ($query) use ($saleChannelId) {
|
||||||
$query->active()->byStockAvailable()->bySaleChannel($saleChannelId);
|
$query->active()->byStockAvailable();
|
||||||
|
|
||||||
|
if ($saleChannelId) {
|
||||||
|
$query->bySaleChannel($saleChannelId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function toSearchableArray(): array
|
||||||
|
{
|
||||||
|
$description = $this->description;
|
||||||
|
$product = $this->product ?? false;
|
||||||
|
|
||||||
|
if (is_object($product)) {
|
||||||
|
$description .= ' ' . $product ? $product->description : '';
|
||||||
|
$description .= ' ' . $product ? $product->plus ?? '' : '';
|
||||||
|
|
||||||
|
$specie = $product ? $product->specie : false;
|
||||||
|
$description .= ' ' . $specie ? $specie->description ?? '' : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => (int) $this->id,
|
||||||
|
'name' => $this->name,
|
||||||
|
'description' => html_entity_decode(strip_tags($description)),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Repositories\Shop;
|
namespace App\Repositories\Shop;
|
||||||
|
|
||||||
|
use App\Models\Shop\Article;
|
||||||
|
|
||||||
class Searches
|
class Searches
|
||||||
{
|
{
|
||||||
|
public static function search($query)
|
||||||
|
{
|
||||||
|
return Article::withAvailableOffers()->search($query)->get();
|
||||||
|
}
|
||||||
public static function getResults($options)
|
public static function getResults($options)
|
||||||
{
|
{
|
||||||
return Articles::getArticlesToSell($options);
|
return Articles::getArticlesToSell($options);
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
"gzero/eloquent-tree": "^3.1",
|
"gzero/eloquent-tree": "^3.1",
|
||||||
"hassankhan/config": "^3.1",
|
"hassankhan/config": "^3.1",
|
||||||
"htmlmin/htmlmin": "^9.0",
|
"htmlmin/htmlmin": "^9.0",
|
||||||
|
"http-interop/http-factory-guzzle": "^1.2",
|
||||||
"intervention/image": "^2.7",
|
"intervention/image": "^2.7",
|
||||||
"jasonlewis/expressive-date": "^1.0",
|
"jasonlewis/expressive-date": "^1.0",
|
||||||
"jenssegers/date": "^4.0",
|
"jenssegers/date": "^4.0",
|
||||||
@@ -59,6 +60,7 @@
|
|||||||
"league/period": "^5.3",
|
"league/period": "^5.3",
|
||||||
"livewire/livewire": "^2.12",
|
"livewire/livewire": "^2.12",
|
||||||
"maatwebsite/excel": "^3.1",
|
"maatwebsite/excel": "^3.1",
|
||||||
|
"meilisearch/meilisearch-php": "^1.6",
|
||||||
"moneyphp/money": "^4.3",
|
"moneyphp/money": "^4.3",
|
||||||
"mpdf/mpdf": "^8.2",
|
"mpdf/mpdf": "^8.2",
|
||||||
"mpociot/teamwork": "^8.1",
|
"mpociot/teamwork": "^8.1",
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Shop\Article;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -132,6 +134,12 @@ return [
|
|||||||
'meilisearch' => [
|
'meilisearch' => [
|
||||||
'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'),
|
'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'),
|
||||||
'key' => env('MEILISEARCH_KEY', null),
|
'key' => env('MEILISEARCH_KEY', null),
|
||||||
|
'index-settings' => [
|
||||||
|
Article::class => [
|
||||||
|
'filterableAttributes'=> ['id', 'name', 'description'],
|
||||||
|
'sortableAttributes' => ['created_at'],
|
||||||
|
],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
15
resources/views/Shop/matomo.blade.php
Normal file
15
resources/views/Shop/matomo.blade.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<!-- Matomo -->
|
||||||
|
<script>
|
||||||
|
var _paq = window._paq = window._paq || [];
|
||||||
|
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
||||||
|
_paq.push(['trackPageView']);
|
||||||
|
_paq.push(['enableLinkTracking']);
|
||||||
|
(function() {
|
||||||
|
var u="//192.168.1.10:2080/";
|
||||||
|
_paq.push(['setTrackerUrl', u+'matomo.php']);
|
||||||
|
_paq.push(['setSiteId', '1']);
|
||||||
|
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||||
|
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<!-- End Matomo Code -->
|
||||||
Reference in New Issue
Block a user