Adding Action Buttons to Custom Page for Form Navigation
Hello, how are you? I have this custom page where I would like to apply action buttons that will go to the form. But I don't know how to set up the HTML. I managed to put the table, and now I need a create action button to open the form.
public function table(Table $table): Table
{
return $table
->query($this->tableQuery())
->columns([
TextColumn::make('name')
->searchable(),
TextColumn::make('city.state.name')
->toggleable(),
TextColumn::make('city.name')
->label('Cidade')
->searchable(),
])
->filters([
//
])
->actions([
Action::make('select')
->label(__('Gerenciar'))
->icon('heroicon-o-academic-cap')
->color('warning')
->action(function ($record) {
if (request()->user()->isAdmin() || request()->user()->schools()->where('school_id', $record->id)->exists()) {
Cookie::queue('SHID', $record->code, 60 * 24 * 30);
Notification::make()
->title("{$record->name}")
->body("Você já pode gerenciar a escola!")
->icon("heroicon-o-check-circle")
->color("success")
->send();
Redirect::to('/admin');
}
}),
], position: ActionsPosition::BeforeColumns);
}
public function form(Form $form): Form
{
// abstract
} public function table(Table $table): Table
{
return $table
->query($this->tableQuery())
->columns([
TextColumn::make('name')
->searchable(),
TextColumn::make('city.state.name')
->toggleable(),
TextColumn::make('city.name')
->label('Cidade')
->searchable(),
])
->filters([
//
])
->actions([
Action::make('select')
->label(__('Gerenciar'))
->icon('heroicon-o-academic-cap')
->color('warning')
->action(function ($record) {
if (request()->user()->isAdmin() || request()->user()->schools()->where('school_id', $record->id)->exists()) {
Cookie::queue('SHID', $record->code, 60 * 24 * 30);
Notification::make()
->title("{$record->name}")
->body("Você já pode gerenciar a escola!")
->icon("heroicon-o-check-circle")
->color("success")
->send();
Redirect::to('/admin');
}
}),
], position: ActionsPosition::BeforeColumns);
}
public function form(Form $form): Form
{
// abstract
}<x-filament-panels::page>
{{ $this->table}}
</x-filament-panels::page><x-filament-panels::page>
{{ $this->table}}
</x-filament-panels::page>