Using query builder for adding fulltext index in Laravel

phplaravelsearchtextfullusingmysqlindexfulltextaddingbuilderquery

Last Update : 2023-09-22 UTC 07:29:47 AM

Answers of > Using query builder for adding fulltext index in Laravel

w3coded full fulltext Stack Overflow for Teams w3coded full fulltext Where developers & technologists w3coded full fulltext share private knowledge with coworkers w3coded full fulltext ,Please be w3coded full fulltext sure to answer the question. Provide details and w3coded full fulltext share your research!,But How can I use Laravel w3coded full fulltext query builder to add fulltext index?,On Laravel w3coded full fulltext >= 6.15.0 you can extend w3coded full fulltext Illuminate\Database\Schema\Grammars\MySqlGrammar w3coded full fulltext and Illuminate\Database\Schema\Blueprint classes w3coded full fulltext like this (e.g. on boot() method of your w3coded full fulltext AppServiceProvider):

On Laravel >= 6.15.0 you can extend Illuminate\Database\Schema\Grammars\MySqlGrammar and Illuminate\Database\Schema\Blueprint classes like this (e.g. on boot() method of your AppServiceProvider):

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Grammars\MySqlGrammar;
use Illuminate\Support\Fluent;

Blueprint::macro('fulltext', function ($columns, $name = null, $algorithm = null)
{
    return $this->indexCommand('fulltext', $columns, $name, $algorithm);
});

Blueprint::macro('dropFulltext', function ($index)
{
    return $this->dropIndexCommand('dropIndex', 'fulltext', $index);
});

MySqlGrammar::macro('compileFulltext', function (Blueprint $blueprint, Fluent $command)
{
    return $this->compileKey($blueprint, $command, 'fulltext');
});

And use it on your migrations like this:

Schema::table('flights', function (Blueprint $table) {
    $table->fulltext(['name', 'airline']);
});

//reverse the migration
Schema::table('flights', function (Blueprint $table) {
    $table->dropFulltext(['name', 'airline']);
});

For multiple Columns/Fields

DB::statement('ALTER TABLE Database.TableName ADD FULLTEXT fulltext_index (Col_1, col_2, col_3)');

Current topics : Using query builder for adding fulltext index in Laravel

Newly Added Questions

Similar Questions

Questions :

How To Group Array Key Value

Last Update : 2023-09-22 UTC 11:55:53 AM

Questions :

PhpStorm Warning For React Attributes In Jsx File With SCSS File

Last Update : 2023-09-22 UTC 11:55:35 AM

Questions :

Why Is The File Not Showing Up In Request.files And In Request.forms Instead?

Last Update : 2023-09-22 UTC 11:55:21 AM

Questions :

Proxying Assets From React App Directory In Slim Framework?

Last Update : 2023-09-22 UTC 11:55:01 AM

Questions :

Laravel 5.4 Can't Run “php Artisan Preset React” Comand

Last Update : 2023-09-22 UTC 11:54:55 AM

Questions :

How To Update Session Values Without Signing Out?

Last Update : 2023-09-22 UTC 11:54:38 AM

Questions :

Array Is Not Visible

Last Update : 2023-09-22 UTC 11:54:27 AM

Questions :

React Routing For Login Using Symfony

Last Update : 2023-09-22 UTC 11:54:14 AM

Questions :

Sanctum With React SPA Returning 419 Page Expired

Last Update : 2023-09-22 UTC 11:53:58 AM

Questions :

How Do I Import An Input String Into Another Page

Last Update : 2023-09-22 UTC 11:53:46 AM

Top
© 2023 W3CODED - All Rights Reserved.