I want to use an $id from one table to show the results of that in another table.
The following code snippet id from my departments table form.
protected function getTableRecordUrlUsing(): ?Closure
{
return fn (Department $record): string => route('sections', $record->id);
}
that $id is sent to my sections table, this is how I am handling it(not working, it's displaying all the sections in the different departments instead of just the one department)
here is the code,
class SectionTable extends Component implements Tables\Contracts\HasTable
{
use Tables\Concerns\InteractsWithTable;
public function mount($id)
{
$this->form->fill([
'section_name' => Section::where('department_id',$id)->pluck('section_name')
]);
}
protected function getTableQuery(): Builder
{
return Section::query();
}
protected function getTableColumns(): array
{
return [
TextColumn::make('section_name')
];
}
public function render(): View
{
return view('livewire.tables.section-table');
}
}