diff --git a/app/Note.php b/app/Note.php index 58405834..fad7fede 100644 --- a/app/Note.php +++ b/app/Note.php @@ -62,6 +62,13 @@ class Note extends Model implements HasMedia */ protected $guarded = ['id']; + /** + * Hide the column used with Laravel Scout. + * + * @var array + */ + protected $hidden = ['searchable']; + /** * The attributes that should be mutated to dates. * @@ -69,6 +76,18 @@ class Note extends Model implements HasMedia */ protected $dates = ['deleted_at']; + /** + * Set the attributes to be indexed for searching with Scout. + * + * @return array + */ + public function toSearchableArray() + { + return [ + 'note' => $this->note, + ]; + } + /** * A mutator to ensure that in-reply-to is always non-empty or null. * diff --git a/composer.json b/composer.json index 2981992d..8c18dfe3 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "lcobucci/jwt": "^3.1", "sensiolabs/security-checker": "^4.0", "laravel/scout": "^1.1", - "algolia/algoliasearch-client-php": "^1.11" + "pmatseykanets/laravel-scout-postgres": "^0.2.0" }, "require-dev": { "fzaninotto/faker": "~1.4", diff --git a/composer.lock b/composer.lock index d062e3bb..fc22ac02 100644 --- a/composer.lock +++ b/composer.lock @@ -4,59 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "f9c5f3db6efad2ea0d257e1240b1370a", + "content-hash": "1c3fcc062b9b6e27bea438f835985c6b", "packages": [ - { - "name": "algolia/algoliasearch-client-php", - "version": "1.11.0", - "source": { - "type": "git", - "url": "https://github.com/algolia/algoliasearch-client-php.git", - "reference": "d4f29a1fe82f3d6361a516276849bd98dd014cc0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/algolia/algoliasearch-client-php/zipball/d4f29a1fe82f3d6361a516276849bd98dd014cc0", - "reference": "d4f29a1fe82f3d6361a516276849bd98dd014cc0", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "php": ">=5.3" - }, - "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.0", - "satooshi/php-coveralls": "0.6.*" - }, - "type": "library", - "autoload": { - "psr-0": { - "AlgoliaSearch": "src/", - "AlgoliaSearch\\Tests": "tests/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Algolia Team", - "email": "contact@algolia.com" - }, - { - "name": "Ryan T. Catlin", - "email": "ryan.catlin@gmail.com" - }, - { - "name": "Jonathan H. Wage", - "email": "jonwage@gmail.com" - } - ], - "description": "Algolia Search API Client for PHP", - "homepage": "https://github.com/algolia/algoliasearch-client-php", - "time": "2016-10-20T11:25:18+00:00" - }, { "name": "anahkiasen/underscore-php", "version": "2.0.0", @@ -2617,6 +2566,61 @@ "description": "Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models", "time": "2016-05-21T08:00:18+00:00" }, + { + "name": "pmatseykanets/laravel-scout-postgres", + "version": "v0.2.0", + "source": { + "type": "git", + "url": "https://github.com/pmatseykanets/laravel-scout-postgres.git", + "reference": "f45230853a367f522bb0551d1641e7e133011ee4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/pmatseykanets/laravel-scout-postgres/zipball/f45230853a367f522bb0551d1641e7e133011ee4", + "reference": "f45230853a367f522bb0551d1641e7e133011ee4", + "shasum": "" + }, + "require": { + "illuminate/contracts": "~5.3", + "illuminate/database": "~5.3", + "illuminate/support": "~5.3", + "laravel/scout": "^1.0", + "php": ">=5.6.4" + }, + "require-dev": { + "mockery/mockery": "^0.9.5", + "phpunit/phpunit": "5.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "ScoutEngines\\Postgres\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Peter Matseykanets", + "email": "pmatseykanets@gmail.com", + "homepage": "https://github.com/pmatseykanets", + "role": "Developer" + } + ], + "description": "PostgreSQL Full Text Search Driver for Laravel Scout", + "homepage": "https://github.com/pmatseykanets/laravel-scout-postgres", + "keywords": [ + "fts", + "full text search", + "laravel", + "laravel scout", + "postgresql", + "search" + ], + "time": "2016-10-07T18:54:49+00:00" + }, { "name": "predis/predis", "version": "v1.1.1", diff --git a/config/app.php b/config/app.php index 533cb4ca..ee0e5969 100644 --- a/config/app.php +++ b/config/app.php @@ -208,6 +208,11 @@ return [ */ Laravel\Scout\ScoutServiceProvider::class, + /* + * Postgres Engine for Scout + */ + ScoutEngines\Postgres\PostgresEngineServiceProvider::class, + ], /* diff --git a/config/scout.php b/config/scout.php index 67f19b54..bcf99efa 100644 --- a/config/scout.php +++ b/config/scout.php @@ -80,4 +80,11 @@ return [ ], ], + 'pgsql' => [ + 'connection' => env('DB_CONNECTION', 'pgsql'), + // You may want to update index documents directly in PostgreSQL (i.e. via triggers). + // In this case you can set this value to false. + 'maintain_index' => true, + ], + ]; diff --git a/database/migrations/2016_12_05_204035_add_search_to_notes.php b/database/migrations/2016_12_05_204035_add_search_to_notes.php new file mode 100644 index 00000000..8fa3d51d --- /dev/null +++ b/database/migrations/2016_12_05_204035_add_search_to_notes.php @@ -0,0 +1,33 @@ + - \ No newline at end of file diff --git a/resources/views/master.blade.php b/resources/views/master.blade.php index 291139e1..ee48752f 100644 --- a/resources/views/master.blade.php +++ b/resources/views/master.blade.php @@ -41,7 +41,6 @@
-Search powered by
The code for {{ env('APP_LONGURL') }}
can be found on GitHub.
Built with love: Colophon