diff --git a/composer.json b/composer.json
index 4e67222..4ca1e6c 100644
--- a/composer.json
+++ b/composer.json
@@ -8,7 +8,9 @@
"php": "^8.0.2",
"october/rain": "^3.3",
"laravel/framework": "^9.0",
- "october/all": "^3.1"
+ "october/all": "^3.1",
+ "laravel/scout": "^10.1",
+ "meilisearch/meilisearch-php": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "^8.5|^9.0"
@@ -36,7 +38,8 @@
"config": {
"preferred-install": "dist",
"allow-plugins": {
- "composer/installers": true
+ "composer/installers": true,
+ "php-http/discovery": true
}
},
"autoload": {
diff --git a/config/scout.php b/config/scout.php
new file mode 100644
index 0000000..6fef803
--- /dev/null
+++ b/config/scout.php
@@ -0,0 +1,147 @@
+ env('SCOUT_DRIVER', 'algolia'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Index Prefix
+ |--------------------------------------------------------------------------
+ |
+ | Here you may specify a prefix that will be applied to all search index
+ | names used by Scout. This prefix may be useful if you have multiple
+ | "tenants" or applications sharing the same search infrastructure.
+ |
+ */
+
+ 'prefix' => env('SCOUT_PREFIX', ''),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Queue Data Syncing
+ |--------------------------------------------------------------------------
+ |
+ | This option allows you to control if the operations that sync your data
+ | with your search engines are queued. When this is set to "true" then
+ | all automatic data syncing will get queued for better performance.
+ |
+ */
+
+ 'queue' => env('SCOUT_QUEUE', false),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Database Transactions
+ |--------------------------------------------------------------------------
+ |
+ | This configuration option determines if your data will only be synced
+ | with your search indexes after every open database transaction has
+ | been committed, thus preventing any discarded data from syncing.
+ |
+ */
+
+ 'after_commit' => false,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Chunk Sizes
+ |--------------------------------------------------------------------------
+ |
+ | These options allow you to control the maximum chunk size when you are
+ | mass importing data into the search engine. This allows you to fine
+ | tune each of these chunk sizes based on the power of the servers.
+ |
+ */
+
+ 'chunk' => [
+ 'searchable' => 500,
+ 'unsearchable' => 500,
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Soft Deletes
+ |--------------------------------------------------------------------------
+ |
+ | This option allows to control whether to keep soft deleted records in
+ | the search indexes. Maintaining soft deleted records can be useful
+ | if your application still needs to search for the records later.
+ |
+ */
+
+ 'soft_delete' => false,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Identify User
+ |--------------------------------------------------------------------------
+ |
+ | This option allows you to control whether to notify the search engine
+ | of the user performing the search. This is sometimes useful if the
+ | engine supports any analytics based on this application's users.
+ |
+ | Supported engines: "algolia"
+ |
+ */
+
+ 'identify' => env('SCOUT_IDENTIFY', false),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Algolia Configuration
+ |--------------------------------------------------------------------------
+ |
+ | Here you may configure your Algolia settings. Algolia is a cloud hosted
+ | search engine which works great with Scout out of the box. Just plug
+ | in your application ID and admin API key to get started searching.
+ |
+ */
+
+ 'algolia' => [
+ 'id' => env('ALGOLIA_APP_ID', ''),
+ 'secret' => env('ALGOLIA_SECRET', ''),
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Meilisearch Configuration
+ |--------------------------------------------------------------------------
+ |
+ | Here you may configure your Meilisearch settings. Meilisearch is an open
+ | source search engine with minimal configuration. Below, you can state
+ | the host and key information for your own Meilisearch installation.
+ |
+ | See: https://docs.meilisearch.com/guides/advanced_guides/configuration.html
+ |
+ */
+
+ 'meilisearch' => [
+ 'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'),
+ 'key' => env('MEILISEARCH_KEY'),
+ 'index-settings' => [
+ Posts::class => [
+ 'sortableAttributes' => ['published_at','created_at','updated_at'],
+ ],
+ // 'users' => [
+ // 'filterableAttributes'=> ['id', 'name', 'email'],
+ // ],
+ ],
+ ],
+
+];
diff --git a/plugins/indikator/news/models/Posts.php b/plugins/indikator/news/models/Posts.php
index f339f55..850c08e 100644
--- a/plugins/indikator/news/models/Posts.php
+++ b/plugins/indikator/news/models/Posts.php
@@ -1,5 +1,8 @@
'title'
];
-
+
protected $jsonable = [
'image'
];
@@ -148,6 +155,21 @@ class Posts extends Model
]
];
+ /**
+ * Get the indexable data array for the model.
+ *
+ * @return array
+ */
+ public function toSearchableArray()
+ {
+ return [
+ 'title' => $this->title,
+ 'slug'=> $this->slug,
+ 'introductory'=> $this->introductory,
+ 'content'=> $this->content
+ ];
+ }
+
public $preview = null;
public function getSendAttribute() {
@@ -416,7 +438,7 @@ class Posts extends Model
public function duplicate($post)
{
$clone = new Posts();
- $clone->title = \Lang::get('indikator.news::lang.form.clone_of').' '.$post->title;
+ $clone->title = Lang::get('indikator.news::lang.form.clone_of').' '.$post->title;
$clone->slug = $post->slug.'-'.now()->format('Y-m-d-h-i-s');
$clone->status = 3;
$clone->introductory = $post->introductory;
@@ -434,7 +456,7 @@ class Posts extends Model
$clone->save();
- \Event::fire('indikator.news.posts.duplicate', [&$clone, $post]);
+ Event::fire('indikator.news.posts.duplicate', [&$clone, $post]);
return $clone;
}
@@ -605,7 +627,7 @@ class Posts extends Model
$page->rewriteTranslatablePageUrl($locale);
$params = ['category' => $item->getCategory()['slug'], 'id' => $item->id, 'slug' => $item->slug];
- $router = new \October\Rain\Router\Router;
+ $router = new Router;
$localeUrl = $router->urlFromPattern($page->url, $params);
return url($locale.$localeUrl);
@@ -704,7 +726,7 @@ class Posts extends Model
}else{
$image = 'article/'. implode('/', array_slice(explode( "-", $image), 0, 3)) . '/'. $image_name;
}
-
+
$imagedata = getimagesize(storage_path("app/uploads/public/". $image));
return $imagedata[0] > $imagedata[1] ? "horizontal" : "vertical";
}
diff --git a/themes/demo/layouts/default.htm b/themes/demo/layouts/default.htm
index e99b14f..783dba3 100644
--- a/themes/demo/layouts/default.htm
+++ b/themes/demo/layouts/default.htm
@@ -15,7 +15,7 @@ forceUrl = 1
-
+
@@ -30,19 +30,18 @@ forceUrl = 1
{% partial 'header' data=activeLocale %}
{% page %}
{% partial 'footer' %}
-
+