Skip to content

Commit 62962df

Browse files
committed
Paginator total override
laravel/framework#46410
1 parent e79b0ae commit 62962df

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Relations/EmbedsMany.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -289,21 +289,22 @@ protected function associateExisting($model)
289289
}
290290

291291
/**
292-
* @param int|null $perPage
293-
* @param array $columns
294-
* @param string $pageName
295-
* @param int|null $page
296292
*
293+
* @param null $perPage
294+
* @param array|string|string[] $columns
295+
* @param string $pageName
296+
* @param null $page
297+
* @param null $total
297298
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
298299
*/
299-
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
300+
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null, $total = null)
300301
{
301302
$page = $page ?: Paginator::resolveCurrentPage($pageName);
302303
$perPage = $perPage ?: $this->related->getPerPage();
303304

304305
$results = $this->getEmbedded();
305306
$results = $this->toCollection($results);
306-
$total = $results->count();
307+
$total = value($total) ?? $results->count();
307308
$start = ($page - 1) * $perPage;
308309

309310
$sliced = $results->slice(

0 commit comments

Comments
 (0)