If I use load it returns Collection instead of LengthAwarePaginator, could please someone advice and why it happens? I can't seem to find the solution for this.
Paginator->load uses a magic method to call the load method on the model collection.
/** @var LengthAwarePaginator $users */
$paginatedResults = User::search($query)->paginate(5);
/** @var User[] $modelCollection */
/*$modelCollection = */ $paginatedResults->load('dealer');
// LengthAwarePaginator->load calls load on the "items" within the paginator
// it @returns a collection, but also updates the existing items within the Paginator
// do not use the return value, continue to use the Paginator $paginatedResults
@MEVLUTOZDEMIR - Just to improve the answer from @mevlutozdemir and @somewhat, you could use Laravel's tap() helper, allowing you to have a single return from your method call: