PHP code example of torann / laravel-cloudsearch
1. Go to this page and download the library: Download torann/laravel-cloudsearch 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/ */
torann / laravel-cloudsearch example snippets
'fields' => [
'title' => 'text',
'status' => 'literal',
],
$post = new App\Post;
// ...
$post->save();
$post = App\Post::find(1);
// Update the post...
$post->save();
$post = App\Post::find(1);
$post->delete();
$posts = App\Post::search('Kitten fluff')->get();
use Illuminate\Http\Request;
Route::get('/search', function (Request $request) {
return App\Post::search($request->search)->get();
});
$posts = App\Post::search('Kitten fluff')->paginate();
$posts = App\Post::search('Kitten fluff')->paginate(15);
$query = app(\LaravelCloudSearch\CloudSearcher::class)->newQuery();
$query->phrase('ford')
->term('National Equipment', 'seller')
->range('year', '2010');
$results = $query->get();
$query = app(\LaravelCloudSearch\CloudSearcher::class)->newQuery();
$results = $query->searchableType(\App\LawnMower::class)
->term('honda', 'name')
->get();
$query->or(function($builder) {
$builder->phrase('ford')
->phrase('truck');
});
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('search:queue')->everyTenMinutes();
}
php
'providers' => [
LaravelCloudSearch\LaravelCloudSearchServiceProvider::class,
]
php
$app->register(LaravelCloudSearch\LaravelCloudSearchServiceProvider::class);
bash
php artisan vendor:publish --provider="LaravelCloudSearch\LaravelCloudSearchServiceProvider" --tag=migrations
bash
$ php artisan migrate