© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•7mo ago•
2 replies
Shaung Bhone

Create action with relation manager

I don't get it about why I need product_id in my stocks relation manager like that?

stock relation manager
protected static string $relationship = 'stocks';

->headerActions([
    Tables\Actions\CreateAction::make()
        ->using(
            fn(array $data, string $model): Model => $model::create([
                'product_id' => $this->ownerRecord->id,
                'remaining_stock' => 0,
                'price' => $data['price'] ?? 0,
                'cost' => $data['cost'] ?? 0,
                'adding_stock' => 0,
                'profit' => $data['profit'] ?? 0,
                'total_price' => 0, // This will be calculated later
            ])
        )
        ->slideOver()
        ->label('Add New')
        ->icon('heroicon-o-plus')
        ->modalWidth(MaxWidth::Large),
])
protected static string $relationship = 'stocks';

->headerActions([
    Tables\Actions\CreateAction::make()
        ->using(
            fn(array $data, string $model): Model => $model::create([
                'product_id' => $this->ownerRecord->id,
                'remaining_stock' => 0,
                'price' => $data['price'] ?? 0,
                'cost' => $data['cost'] ?? 0,
                'adding_stock' => 0,
                'profit' => $data['profit'] ?? 0,
                'total_price' => 0, // This will be calculated later
            ])
        )
        ->slideOver()
        ->label('Add New')
        ->icon('heroicon-o-plus')
        ->modalWidth(MaxWidth::Large),
])
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

Open relation manager create modal from table action
FilamentFFilament / ❓┊help
3y ago
Refresh relation manager from action
FilamentFFilament / ❓┊help
2y ago
Custom Action from Relation Manager
FilamentFFilament / ❓┊help
2y ago
Relation manager in action/modal
FilamentFFilament / ❓┊help
3y ago