Using meilisearch scout, and want to get specific columns only on response. (To descrease the result size)
$products = Product::search('blabla')
->select('title', 'id')
->paginate($paginate)
->load(['cover']);
But it returns error like that
Method Laravel\Scout\Builder::select does not exist
How can I pick specific columns?
If you're trying to retrieve the data using ->paginate() method, you must need to load the relations separately. For example:
$products = Product::search('blabla')
->query(function($query) {
$query->addSelect(['title', 'id']);
})
->paginate($paginate);
$products->load(['cover']);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.