© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
black ka1ser

after() method of DetachAction is not working

for AttachAction it is working:

->headerActions([
                Tables\Actions\AttachAction::make()
                    ->label('Attach topic')
                    ->after(
                        function (RelationManager $livewire, $data) {
                            // save all the questions of the attached topic into QuizQuestion

                            // 1. get all the questions of the topic, from Topicable
                            $questionIds = Topicable::where([
                                ['topic_id', $data],
                                ['topicable_type', 'Harishdurga\LaravelQuiz\Models\Question'],
                            ])->pluck('topicable_id');

                            // 2. insert quizId and questionId into QuizQuestion
                            foreach ($questionIds as $questionId) {
                                QuizQuestion::create([
                                    'quiz_id' => $livewire->ownerRecord->id,
                                    'question_id' => $questionId,
                                ]);
                            }
                        }
                    )
            ])
->headerActions([
                Tables\Actions\AttachAction::make()
                    ->label('Attach topic')
                    ->after(
                        function (RelationManager $livewire, $data) {
                            // save all the questions of the attached topic into QuizQuestion

                            // 1. get all the questions of the topic, from Topicable
                            $questionIds = Topicable::where([
                                ['topic_id', $data],
                                ['topicable_type', 'Harishdurga\LaravelQuiz\Models\Question'],
                            ])->pluck('topicable_id');

                            // 2. insert quizId and questionId into QuizQuestion
                            foreach ($questionIds as $questionId) {
                                QuizQuestion::create([
                                    'quiz_id' => $livewire->ownerRecord->id,
                                    'question_id' => $questionId,
                                ]);
                            }
                        }
                    )
            ])
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

AssociateAction and DetachAction
FilamentFFilament / ❓┊help
3y ago
Delete method inside model policy not working after editing
FilamentFFilament / ❓┊help
6mo ago
Action authorize() method not working
FilamentFFilament / ❓┊help
6mo ago
wire:click not working inside of custom field, method not found.
FilamentFFilament / ❓┊help
3y ago