我需要对结果进行分页并使用 sortBy() 对它们进行排序,而不丢失分页链接。我还需要使用资源来返回结果。
$sorted = Model::paginate(10)->sortBy('name');
$results = \App\Http\Resources\MyResource::collection($sorted);
Run Code Online (Sandbox Code Playgroud)
这样做会破坏分页链接(我只得到数据部分)。
$paginated = Model::paginate(10);
$results = \App\Http\Resources\MyResource::collection($paginated);
return $results->sortBy('name');
Run Code Online (Sandbox Code Playgroud)
这也是行不通的。有任何想法吗?
如何在Xamarin.Forms(iOS)中更改Tab栏的高度?TabbedRenderer可以吗?
我想按名称列对集合进行排序。使用 sortBy() 方法不起作用。
$collection = \App\Http\Resources\MyResource::collection($test);
return $collection->sortBy('name');
Run Code Online (Sandbox Code Playgroud)