class ListExhibitions extends Component implements HasForms, HasTable
{
use InteractsWithForms;
use InteractsWithTable;
public Winery $winery;
public function mount(Winery $winery): void
{
$this->winery = $winery;
}
public function table(Table $table): Table
{
return $table
->recordClasses("padding-top-0")
->query(Exhibition::query()->where('active',1))
->columns([
Tables\Columns\TextColumn::make('country')->sortable(),
Tables\Columns\CheckboxColumn::make('AC')
->state(function (Exhibition $record): bool {
return $record->wineries->contains($this->winery) ? true : false;
})
->updateStateUsing(function (Exhibition $record, $state) {
if ($state) {
$record->wineries()->attach($this->winery->id);
} else {
$record->masterclass ? $record->masterclass->wineries()->detach($this->winery->id) : "";
$record->wineries()->detach($this->winery->id);
}
})
->label('P'),
]);
}
public function render(): View
{
return view('livewire.exhibitions.list-exhibitions');
}
}
class ListExhibitions extends Component implements HasForms, HasTable
{
use InteractsWithForms;
use InteractsWithTable;
public Winery $winery;
public function mount(Winery $winery): void
{
$this->winery = $winery;
}
public function table(Table $table): Table
{
return $table
->recordClasses("padding-top-0")
->query(Exhibition::query()->where('active',1))
->columns([
Tables\Columns\TextColumn::make('country')->sortable(),
Tables\Columns\CheckboxColumn::make('AC')
->state(function (Exhibition $record): bool {
return $record->wineries->contains($this->winery) ? true : false;
})
->updateStateUsing(function (Exhibition $record, $state) {
if ($state) {
$record->wineries()->attach($this->winery->id);
} else {
$record->masterclass ? $record->masterclass->wineries()->detach($this->winery->id) : "";
$record->wineries()->detach($this->winery->id);
}
})
->label('P'),
]);
}
public function render(): View
{
return view('livewire.exhibitions.list-exhibitions');
}
}