afiq593
Repeater with relationship and group by
Hi i am trying to use repeater in a form schema. Where i would like to group by a column name.
Sample code:
Repeater::make('cash_out')
->schema([
Placeholder::make('month')
->label('')
->content(static fn ($state) => $state),
Placeholder::make('total')
->label('')
->content(static fn ($state) => $state),
])
->relationship('cash', function ($query){
return $query->select('month')
->selectRaw('SUM(amount) as total')
->groupBy('month');
})
->columns(1),
2 replies