label('新建教材'), ]; } protected function paginateTableQuery(\Illuminate\Database\Eloquent\Builder $query): Paginator { $apiService = app(TextbookApiService::class); $page = request()->get('page', 1); $perPage = $this->getTableRecordsPerPage(); $result = $apiService->getTextbooks([ 'page' => $page, 'per_page' => $perPage, ]); $records = collect($result['data'] ?? [])->map(function ($item) { return new \App\Models\Textbook($item); }); return new LengthAwarePaginator( $records, $result['meta']['total'] ?? 0, $perPage, $page, ['path' => request()->url()] ); } }