Skip to content

Instantly share code, notes, and snippets.

@azeemhassni
Last active May 17, 2016 19:42
Show Gist options
  • Save azeemhassni/7d903d142b2ac88963ae65a87079b63b to your computer and use it in GitHub Desktop.
Save azeemhassni/7d903d142b2ac88963ae65a87079b63b to your computer and use it in GitHub Desktop.
TNT Search Product Indexer Artisan Command
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use TeamTNT\TNTSearch\Facades\TNTSearch;
class ProductIndexer extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'index:products';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Index the Products';
/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$indexer = TNTSearch::createIndex('products.index');
$indexer->query("SELECT id, title, description, price FROM products");
$indexer->run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment