laravel scout 中的限制和偏移

ujw*_*kal 1 pagination laravel laravel-scout

我正在使用 scout 作为我的 api,所以不能使用分页,因为 scout 仅提供分页,所以有什么方法可以在 laravel scout 中使用偏移量和限制?

小智 5

你可以使用方法 take()

$result = YourModel::search('query')->take(20)->raw()
Run Code Online (Sandbox Code Playgroud)

或者

$result = YourModel::search('query')->take(20)->get()
Run Code Online (Sandbox Code Playgroud)