Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scout 9 #48

Open
robert-abram opened this issue Jan 17, 2022 · 4 comments
Open

Scout 9 #48

robert-abram opened this issue Jan 17, 2022 · 4 comments

Comments

@robert-abram
Copy link

Helo, when scout 9.x will be support ?

@devNoiseConsulting
Copy link

Would like to 2nd this question/issue. Laravel 8 is going to stop getting bug fixes next week (July 26, 2022). This package is useful to me and would like to continue using it in the newer versions of Laravel.

@AlbinoDrought
Copy link

AlbinoDrought commented Aug 5, 2022

If you don't care about new Scout 9 features and just want to upgrade, this patch implements stubs for the new Scout 9 methods:

From 91743119444f97a6f289e17827cfc8309f51d1cd Mon Sep 17 00:00:00 2001
From: AlbinoDrought <snip>
Date: Fri, 5 Aug 2022 07:38:13 -0700
Subject: [PATCH] feat: Laravel 9 support

---
 composer.json          | 10 +++++-----
 src/PostgresEngine.php | 21 +++++++++++++++++++--
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/composer.json b/composer.json
index 305a86c..5007ed1 100644
--- a/composer.json
+++ b/composer.json
@@ -23,11 +23,11 @@
         }
     ],
     "require": {
-        "php": "^7.2|^8.0",
-        "illuminate/contracts": "~6.0|~7.0|~8.0",
-        "illuminate/database": "~6.0|~7.0|~8.0",
-        "illuminate/support": "~6.0|~7.0|~8.0",
-        "laravel/scout": "~7.0|~8.0"
+        "php": "^8.0",
+        "illuminate/contracts": "^9.0",
+        "illuminate/database": "^9.0",
+        "illuminate/support": "^9.0",
+        "laravel/scout": "^9.0"
     },
     "require-dev": {
         "phpunit/phpunit": "^8.3",
diff --git a/src/PostgresEngine.php b/src/PostgresEngine.php
index b92b3e0..8504090 100644
--- a/src/PostgresEngine.php
+++ b/src/PostgresEngine.php
@@ -6,6 +6,7 @@ use Illuminate\Database\ConnectionResolverInterface;
 use Illuminate\Database\Eloquent\Collection;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Arr;
+use Illuminate\Support\LazyCollection;
 use Laravel\Scout\Builder;
 use Laravel\Scout\Engines\Engine;
 use ScoutEngines\Postgres\TsQuery\PhraseToTsQuery;
@@ -75,7 +76,6 @@ class PostgresEngine extends Engine
      * Perform update of the given model.
      *
      * @param \Illuminate\Database\Eloquent\Model $model
-     * @return bool
      */
     protected function performUpdate(Model $model)
     {
@@ -339,6 +339,24 @@ class PostgresEngine extends Engine
             });
     }
 
+    public function lazyMap(Builder $builder, $results, $model)
+    {
+        // not supported
+        return new LazyCollection(
+            $this->map($builder, $results, $model)
+        );
+    }
+
+    public function createIndex($name, array $options = [])
+    {
+        return null;
+    }
+
+    public function deleteIndex($name)
+    {
+        return null;
+    }
+
     /**
      * Connect to the database.
      */
@@ -389,7 +407,6 @@ class PostgresEngine extends Engine
      * Get rank function.
      *
      * @param \Illuminate\Database\Eloquent\Model $model
-     * @return int
      */
     protected function rankFunction(Model $model)
     {
-- 
2.37.1

(the changed PHPDoc is due to Psalm complaints, rankFunction actually returns string, performUpdate actually returns int|bool)

@AlbinoDrought
Copy link

Following the above patch to Scout 9, the BC-break changes in Laravel 10 and Scout 10 do not impact this package:

From da73332097fbff3a694f3fb7d0a08e01a78066be Mon Sep 17 00:00:00 2001
From: AlbinoDrought <snip>
Date: Thu, 16 Mar 2023 11:15:06 -0700
Subject: [PATCH] feat: Laravel 10, Scout 10 support

---
 composer.json | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/composer.json b/composer.json
index 5007ed1..6146c4f 100644
--- a/composer.json
+++ b/composer.json
@@ -24,10 +24,10 @@
     ],
     "require": {
         "php": "^8.0",
-        "illuminate/contracts": "^9.0",
-        "illuminate/database": "^9.0",
-        "illuminate/support": "^9.0",
-        "laravel/scout": "^9.0"
+        "illuminate/contracts": "^10.0 || ^9.0",
+        "illuminate/database": "^10.0 || ^9.0",
+        "illuminate/support": "^10.0 || ^9.0",
+        "laravel/scout": "^10.0 || ^9.0"
     },
     "require-dev": {
         "phpunit/phpunit": "^8.3",
-- 
2.38.1

@devNoiseConsulting
Copy link

@AlbinoDrought I've not seen any responses or updates, I've forked this project and am trying to update/maintain the driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants