F
Filament14mo ago
Askancy

Using an eloquent query for the form

I am using to compose the table, the model "component_pivot", while for the form I would need to use the model component, how can I do that?
protected static ?string $model = Component_pivot::class;
protected static ?string $model = Component_pivot::class;
For the form I would need to use this eloquent query:
\App\Models\Component::with('component_pivot')->where('group_id', '1')->get()
\App\Models\Component::with('component_pivot')->where('group_id', '1')->get()
3 Replies
Askancy
AskancyOP14mo ago
any idea?
toeknee
toeknee14mo ago
So you are trying to render a pivot model? opposed to the model/
Askancy
AskancyOP14mo ago
I solved with:
protected function getTableQuery(): Builder
{
return parent::getTableQuery()->with('other')->groupBy('group_id', 'id_game');
}
protected function getTableQuery(): Builder
{
return parent::getTableQuery()->with('other')->groupBy('group_id', 'id_game');
}
but I have another problem: With this query now I no longer use the pivot table, I can do everything with one table. Basically it works like this: In the table it shows the names of the games by grouping the achiviements by id_game and id_console, by doing this I avoid having duplicate results in the table. But now when I click on a result, it shows me only one achiviements. I would like to have all the achiviements of that game displayed, so it should run the query: Trofei::where('id_console', $id_console)->where('id_gioco', $id_game)->get() As you see in the screen it shows only one TextInput, instead I would like it to show all the items that only related to that $id_game and $id_console
No description
No description
Want results from more Discord servers?
Add your server