Last active
May 17, 2016 19:42
-
-
Save azeemhassni/7d903d142b2ac88963ae65a87079b63b to your computer and use it in GitHub Desktop.
TNT Search Product Indexer Artisan Command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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