【发布时间】:2018-09-04 15:46:59
【问题描述】:
我在 Laravel 5.6 上使用 Algolia。我按照 Laravel 文档上的教程进行操作。
$searches = Application::search($query)->get();
集合 {#243 ▼ #items: [] }
当我搜索应用程序时,结果返回给我 0 项。
我输入这个命令:
php artisan scout:import "App\Models\Application"
在 Algolia 上发送项目,并且它们出现在 Algolia 仪表板上,我可以看到它。
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;
class Application extends Model
{
use Searchable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'user_id',
'title',
'slug',
'short_description',
'long_description',
'state',
];
/**
* @return string
*/
public function searchableAs()
{
return 'applications';
}
/**
* @return mixed
*/
public function getScoutKey()
{
return $this->title;
}
}
【问题讨论】:
标签: php laravel laravel-5.6 algolia