...
class Index extends Component implements HasTable
{
use InteractsWithTable;
public $wedding_id; // This is from URL query string
protected Wedding $wedding;
public function mount(): void
{
$this->wedding = Wedding::findOrFail($this->wedding_id);
}
protected function getTableQuery(): Builder
{
return $this->wedding->budgetItemsQuery();
// This function only returns a Builder in the model like this:
// public function budgetItemsQuery(): Builder
// {
// return Item::where('budget_id', $this->budget->id);
// }
}
protected function getTableColumns(): array
{
return [
TextColumn::make('title'),
TextColumn::make('value'),
];
}
protected function getTableActions(): array
{
return [
Action::make('edit')
->color('warning')
->icon('heroicon-o-pencil')
->action(function () {
return $this->emit('openModal', 'item.edit');
})
];
}
}
...
class Index extends Component implements HasTable
{
use InteractsWithTable;
public $wedding_id; // This is from URL query string
protected Wedding $wedding;
public function mount(): void
{
$this->wedding = Wedding::findOrFail($this->wedding_id);
}
protected function getTableQuery(): Builder
{
return $this->wedding->budgetItemsQuery();
// This function only returns a Builder in the model like this:
// public function budgetItemsQuery(): Builder
// {
// return Item::where('budget_id', $this->budget->id);
// }
}
protected function getTableColumns(): array
{
return [
TextColumn::make('title'),
TextColumn::make('value'),
];
}
protected function getTableActions(): array
{
return [
Action::make('edit')
->color('warning')
->icon('heroicon-o-pencil')
->action(function () {
return $this->emit('openModal', 'item.edit');
})
];
}
}