zidd
zidd
FFilament
Created by zidd on 12/9/2024 in #❓┊help
Wrong Pivot Values
So i've implement ulid as primary key on my table, when submit the data mysql error like this:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`cita-kita`.`blog_category_blog_post`, CONSTRAINT `blog_category_blog_post_blog_post_id_foreign` FOREIGN KEY (`blog_post_id`) REFERENCES `blog_posts` (`id`) ON DELETE CASCADE) (Connection: mysql, SQL: insert into `blog_category_blog_post` (`blog_category_id`, `blog_post_id`) values (01jenzmcnwkzh12v47xbf65vdr, 1))
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`cita-kita`.`blog_category_blog_post`, CONSTRAINT `blog_category_blog_post_blog_post_id_foreign` FOREIGN KEY (`blog_post_id`) REFERENCES `blog_posts` (`id`) ON DELETE CASCADE) (Connection: mysql, SQL: insert into `blog_category_blog_post` (`blog_category_id`, `blog_post_id`) values (01jenzmcnwkzh12v47xbf65vdr, 1))
Why the value of blog_post_id is = 1 instead of ulid value? Here's the code
Select::make('categories')
->multiple()
->preload()
->createOptionForm(BlogCategory::getForm())
->searchable()
->relationship('categories', 'name')
->columnSpanFull(),
Select::make('categories')
->multiple()
->preload()
->createOptionForm(BlogCategory::getForm())
->searchable()
->relationship('categories', 'name')
->columnSpanFull(),
1 replies
FFilament
Created by zidd on 12/2/2024 in #❓┊help
Bulk Action Button on Modal Submit
I'm trying to create an action to add transaction data to delivery data. So i've view delivery page on that file i have function to open add transaction modal like this
ViewDelivery.php
public function addTransactionAction(): Action
{
return Action::make('addTransaction')
->label('Add Transaction')
->modal()
->modalContent(fn (Delivery $delivery): View => view(
'filament.modals.transaction-list',
['delivery' => $delivery]
))
->action();
}
ViewDelivery.php
public function addTransactionAction(): Action
{
return Action::make('addTransaction')
->label('Add Transaction')
->modal()
->modalContent(fn (Delivery $delivery): View => view(
'filament.modals.transaction-list',
['delivery' => $delivery]
))
->action();
}
And that will render a livewire component like this
ListTransaction.php

Delivery $delivery;
public function table(Table $table): Table
{
return $table
->query(Transaction::query())
->columns([
Tables\Columns\TextColumn::make('transaction_number')
->searchable(),
Tables\Columns\TextColumn::make('customer_name')
->searchable(),
])
->filters([
//
])
->actions([
//
])
->bulkActions([
BulkAction::make('select')
->deselectRecordsAfterCompletion(),
]);
}

public function render(): View
{
return view('livewire.transaction.list-transaction');
}
ListTransaction.php

Delivery $delivery;
public function table(Table $table): Table
{
return $table
->query(Transaction::query())
->columns([
Tables\Columns\TextColumn::make('transaction_number')
->searchable(),
Tables\Columns\TextColumn::make('customer_name')
->searchable(),
])
->filters([
//
])
->actions([
//
])
->bulkActions([
BulkAction::make('select')
->deselectRecordsAfterCompletion(),
]);
}

public function render(): View
{
return view('livewire.transaction.list-transaction');
}
Can i set the bulk action submit on the modal submit? I want to set delivery_id on transactions table when modal submit is triggered
2 replies