Estoy usando:
"require": {
"php": "^7.1.3",
"barryvdh/laravel-cors": "^0.11.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0",
"maatwebsite/excel": "^3.1",
"phpoffice/phpspreadsheet": "^1.8"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.5"
},
requiero hacer está consulta con eloquent:
select `UserId`, count(EstOriId) AS count_start
from `servicio` group by `EstOriId`
Estoy intentando realizar está consulta utilizando Laravel con Eloquent:
public function report5()
{
$data = DB::table('servicio')
->select('UserId', DB::raw('count(EstOriId) AS count_start'))
->groupBy('EstOriId')
->paginate(6);
return $data;
}
Sin embargo me sale esté error al momento de hacer la petición:
"SQLSTATE[42000]: Syntax error or access violation: 1055 'bici.servicio.UserId' isn't in GROUP BY (SQL: select
UserId
, count(EstOriId) AS count_start fromservicio
group byEstOriId
limit 6 offset 0) ◀"
Ya configure en el config\database.php, como proponen para intentar solucionar este inconveniente:
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => false,
'modes' => [
'NO_ZERO_DATE',
'ONLY_FULL_GROUP_BY',
],
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],