Open EpikkuH opened 1 year ago
I suggest trying it without the ->where('product_id','=',$this->id);
in your query.
...edit Sorry, I didn't pay attention enough attention to your issue description :(. Have you looked at the request going to the server? I probably not passing the id. And I don't see where that is configurable.
I suggest trying it without the
->where('product_id','=',$this->id);
in your query....edit Sorry, I didn't pay attention enough attention to your issue description :(. Have you looked at the request going to the server? I probably not passing the id. And I don't see where that is configurable.
It's alright yeah it seems the id gets lost and i don't see any way to make it work at least for now, if it's not possible right know it definitely should be in the future thanks for your time anyways
I have fixed this issue by editing the core files of the Splade.
Here is step by step how I have successfully was able to send the ID that is associated with a relationship with the records inside the data table:
Step 1: Define Extra Parameters in BulkAction Class
Add a method in the BulkAction class to set extra parameters.
// In BulkAction.php public function setExtraParameters(array $extraParameters) { $this->extraParameters = $extraParameters; }
Step 2: Set Extra Parameters in HasBulkActions Trait When defining a bulk action, set the extra parameters. `// In HasBulkActions.php public function bulkAction( // ... other parameters, array $extraParameters = [] ): self { // ... existing code to set up bulk action
$this->bulkActions[$key]->setExtraParameters($extraParameters);
return $this;
} `
Step 3: Pass Product ID as an Extra Parameter
In your ProductReviews table configuration, pass the productId.
// In ProductReviews.php $table->bulkAction( label: 'Delete Selected', // ... other parameters, extraParameters: ['productId' => $this->productId] );
Step 4: Access Product ID in the Bulk Action Method
Retrieve the productId within the deleteSelectedReviews method using the request helper.
// In ProductReviews.php protected function deleteSelectedReviews($selectedIds) { $productId = request('wildId'); // ... existing deletion logic }
Step 5: Use Extra Parameters in Blade Template Modify the Blade template to use the extra parameters in the getUrl method. `{{-- In your Blade template --}} @foreach($table->getBulkActions() as $bulkAction) <button v-if="table.hasSelectedItems" @click.prevent="table.performBulkAction( @js($bulkAction->getUrl(['wildId' => $bulkAction->extraParameters])), // ... other parameters )" dusk="action.{{ $bulkAction->getSlug() }}"
{{ $bulkAction->label }} @endforeach `
These steps ensure that the productId is passed as an additional parameter when defining bulk actions and is accessible within the method that performs the bulk deletion. The use of @js in the Blade template ensures the JavaScript code has the correct parameters passed from the server side.
Description:
I am using the table class because i need to do exports but i am having problems because i need a $id for the query which i get from the request and it is lost by the time i export the table someone haves any idea how i could approach this?
Steps To Reproduce Issue:
on my table class:
everything works except the export which returns an empty table instead of the same one it originally shows