PHP code example of luozhenyu / laravel-postgresql-fulltext

1. Go to this page and download the library: Download luozhenyu/laravel-postgresql-fulltext library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

luozhenyu / laravel-postgresql-fulltext example snippets


php artisan vendor:publish --provider="LuoZhenyu\PostgresFullText\PostgresqlSchemaServiceProvider"

LuoZhenyu\PostgresFullText\PostgresqlSchemaServiceProvider::class

Schema::create('users', function(Blueprint $table) {
  $table->increments('id');
  $table->string('name');
  $table->integer('age');
});

Schema::create('admins', function(Blueprint $table) {
    $table->string('permission');
    
    $table->inherits('users');//table admins inherit table users
});

Schema::create('articles', function(Blueprint $table) {
  $table->increments('id');
  $table->string('title');
  $table->text('content');
  
  $table->fulltext(['title', 'content']);
  
  $table->dropFulltext('articles_title_content_fulltext');
});


use LuoZhenyu\PostgresFullText\FulltextBuilder;

...

$fulltext = new FulltextBuilder(['title', 'content']);

$articles = Article::where($fulltext->search('any keyword'))->get();