Closed azamudio1971 closed 11 months ago
searching in google i find this https://github.com/laravel/framework/issues/18460
How can I solve it without modifying the vendor?
Extend the firebird driver and modify it then.
I'm with a same problem too. Have you any news about it?
I got it using the simplePagination function! Hope it help you.
$users = User::all();
$users = $this->paginate($users)->setPath($request->url());
paginate function:
protected function paginate($items, $perPage = 12){
$currentPage = LengthAwarePaginator::resolveCurrentPage();
$currentPageItems = $items->slice(($currentPage - 1) * $perPage, $perPage);
return new LengthAwarePaginator($currentPageItems, count($items), $perPage);
}
try this
Here's my workaround:
Create new file in App\Database\Query\
named FirebirdQueryBuilder.php
that has fix in it:
<?php
namespace App\Database\Query;
use Firebird\Query\Builder as BaseBuilder;
class FirebirdQueryBuilder extends BaseBuilder {
/**
* AGGREGATE fix
*
* Get the count of the total records for the paginator.
*
* @param array $columns
* @return int
*/
public function getCountForPagination($columns = ['*'])
{
$results = $this->runPaginationCountQuery($columns);
// Once we have run the pagination count query, we will get the resulting count and
// take into account what type of query it was. When there is a group by we will
// just return the count of the entire results set since that will be correct.
if (isset($this->groups)) {
return count($results);
} elseif (! isset($results[0])) {
return 0;
} elseif (is_object($results[0])) {
return (int) $results[0]->AGGREGATE;
} else {
return (int) array_change_key_case((array) $results[0])['aggregate'];
}
}
}
Than in your BaseModel.php
that extends Firebird\Model
override newBaseQueryBuilder()
method,
and use new FirebirdQueryBuilder
that we created:
<?php
namespace App;
use Firebird\Model as Model;
use Illuminate\Http\Request as FormRequest;
use App\Database\Query\FirebirdQueryBuilder as QueryBuilder;
class BaseModel extends Model
{
/**
* Get a new query builder instance for the connection.
*
* @return \Illuminate\Database\Query\Builder
*/
protected function newBaseQueryBuilder()
{
$connection = $this->getConnection();
return new QueryBuilder(
$connection, $connection->getQueryGrammar(), $connection->getPostProcessor()
);
}
}
And that's it! Hope it helps. Cheers.
I still have problem with paginate, Undefined property: stdClass::$aggregate
i'm using support 5.5. when i want paginate results, laravel return this screens
any idea?