I have actions like this in a resource (replicate and edit):
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('base_currency.name')->sortable(),
Tables\Columns\TextColumn::make('target_currency.name')->sortable(),
Tables\Columns\TextColumn::make('rate'),
Tables\Columns\TextColumn::make('created_at')->dateTime()->sortable(),
Tables\Columns\IconColumn::make('is_current')
->boolean()
->trueIcon('heroicon-o-badge-check')
->falseIcon('heroicon-o-x-circle'),
])
->defaultSort('created_at', 'desc')
->filters([
Tables\Filters\SelectFilter::make('base_currency_id')
->options(Currency::getAll()->mapWithKeys(function ($currency, $key) {
return [$currency->id => $currency->code];
}))
->label('Base currency'),
Tables\Filters\SelectFilter::make('target_currency_id')
->options(Currency::getAll()->mapWithKeys(function ($currency, $key) {
return [$currency->id => $currency->code];
}))
->label('Target currency'),
Tables\Filters\Filter::make('is_current')
->query(fn(Builder $query): Builder => $query->where('is_current', true))
->label('Current only')
->default(),
])
->actions([
Tables\Actions\ReplicateAction::make('replicate')
->beforeReplicaSaved(
function (Model $replica): void {
$replica->is_current = true;
ExchangeRate::query()->where([
'base_currency_id' => $replica->base_currency_id,
'target_currency_id' => $replica->target_currency_id,
'is_current' => true,
])
->update(['is_current' => false]);
}
)
->after(fn (Model $record) => route('exchange-rates.edit', $record)),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}
It is necessary in after to make it so that after replicate the record, the transition to the page with editing is carried out, similar to the EditAction action, how to do this?
after(fn (Model $record) => route('exchange-rates.edit', $record))
This doesn't work because no registered route