You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use Summarize but not appears in the view, just the columns without grouping or couting.
`<?php
namespace App\Filament\Widgets;
use App\Models\Order;
use Filament\Tables\Columns\Summarizers\Summarizer;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget;
use Illuminate\Database\Eloquent\Builder;
class OrdersByUtmCampaignTable extends TableWidget
{
public Builder $query;
If I use selectRaw with count, I got MySQL error.
`<?php
namespace App\Filament\Widgets;
use App\Models\Order;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget;
class OrdersByUtmCampaignTable extends TableWidget
{
protected static ?string $heading = 'Pedidos por Campanha UTM';
public function getTableRecordKey($record): string
{
return 'utm_campaign';
}
public function table(Table $table): Table
{
return $table->query(Order::query())
->modifyQueryUsing(function ($query) {
$query->selectRaw('MIN(id) as id, utm_campaign as id, utm_campaign, count(*) as count')
->groupBy('utm_campaign')
->orderBy('count', 'desc');
})->columns([
TextColumn::make('utm_campaign')
->label('Campanha UTM')
->sortable()
->searchable(),
TextColumn::make('count')
->label('QTD')
->sortable()
->searchable()]);
}
}
**Result:** Illuminate\Database\QueryException vendor/laravel/framework/src/Illuminate/Database/Connection.php:824 SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'laravel.orders.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (Connection: mysql, SQL: select MIN(id) as id, utm_campaign as id, utm_campaign, count(*) as count fromorderswhereorders.deleted_atis null group byutm_campaignorder bycountdesc,orders.id` asc limit 11 offset 0)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Package
Widgets
Package Version
v4.0.0
How can we help you?
I'm trying to use Summarize but not appears in the view, just the columns without grouping or couting.
`<?php
namespace App\Filament\Widgets;
use App\Models\Order;
use Filament\Tables\Columns\Summarizers\Summarizer;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget;
use Illuminate\Database\Eloquent\Builder;
class OrdersByUtmCampaignTable extends TableWidget
{
public Builder $query;
}

`
Result:
If I use selectRaw with count, I got MySQL error.
`<?php
namespace App\Filament\Widgets;
use App\Models\Order;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Filament\Widgets\TableWidget;
class OrdersByUtmCampaignTable extends TableWidget
{
protected static ?string $heading = 'Pedidos por Campanha UTM';
}
**Result:** Illuminate\Database\QueryException vendor/laravel/framework/src/Illuminate/Database/Connection.php:824 SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'laravel.orders.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (Connection: mysql, SQL: select MIN(id) as id, utm_campaign as id, utm_campaign, count(*) as count fromorderswhereorders.deleted_atis null group byutm_campaignorder bycountdesc,orders.id` asc limit 11 offset 0)LARAVEL
12.37.0
PHP
8.4.13
UNHANDLED
CODE 42000
Beta Was this translation helpful? Give feedback.
All reactions