How do I transfer data between pages?

Hello, I want to transfer the Ids of the products I have selected here to the products section in the 2nd picture. Only the parts with the product ID here should come. What I want to ask exactly is that when I add another menu under the 3 points and press there, how can I transfer the information in these selected products to the other page and how exactly can I capture this data on that page? For example, if there are 3 products and 2 of them are selected, 2 of their barcodes should go, I hope I was able to explain.
13 Replies
Dennis Koch
Dennis Koch2y ago
1) Create a bulk action 2) Either store the ids of your $records in session or append them as a query param 3) Redirect to your target page 4) Load your data on the page inside mount() method
Mehmet K.
Mehmet K.OP2y ago
I wonder if I need to proceed in this way, I wasn't exactly sure. Do you have a chance to give an example of how I will send when I select more than one record?
Dennis Koch
Dennis Koch2y ago
->pluck() the ids or barcodes
Mehmet K.
Mehmet K.OP2y ago
I could not do the redirect operation, is this not available in BulckAction?

BulkAction::make('sendProducts')
->action(function (Collection $records, array $data): void {
$records->pluck('barcode_number');
})

BulkAction::make('sendProducts')
->action(function (Collection $records, array $data): void {
$records->pluck('barcode_number');
})
Dennis Koch
Dennis Koch2y ago
I haven't tried yet. Where's the redirect? It Laravel related not Filament
Mehmet K.
Mehmet K.OP2y ago
BulkAction::make('sendProducts')
->action(function (Collection $records, array $data): void {
$barcodeNumbers = $records->pluck('barcode_number');
$url = url('show-selected-products', ['barcode_numbers' => $barcodeNumbers]);
redirect($url)->send();
});
BulkAction::make('sendProducts')
->action(function (Collection $records, array $data): void {
$barcodeNumbers = $records->pluck('barcode_number');
$url = url('show-selected-products', ['barcode_numbers' => $barcodeNumbers]);
redirect($url)->send();
});
I tried it this way but it doesn't work.
Dennis Koch
Dennis Koch2y ago
You didn't return anything. What if you return that redirect response? Not sure whether it's possible Is return redirect($url); doing anything?
Mehmet K.
Mehmet K.OP2y ago
BulkAction::make('sendProducts')
->action(function (Collection $records, array $data) {
$barcodeNumbers = $records->pluck('barcode_number');
return redirect()->route('filament.resources.order-exits.create', ['barcode_numbers' => $barcodeNumbers]);

})
BulkAction::make('sendProducts')
->action(function (Collection $records, array $data) {
$barcodeNumbers = $records->pluck('barcode_number');
return redirect()->route('filament.resources.order-exits.create', ['barcode_numbers' => $barcodeNumbers]);

})
I sent it this way.
public function mount($barcode_numbers)
{
$this->barcode_number = $barcode_numbers;
}
public function mount($barcode_numbers)
{
$this->barcode_number = $barcode_numbers;
}
Forms\Components\Card::make([
Repeater::make('OrdersItem')->label('Ürünler')
->relationship()
->schema([
Select::make('product_order_id')->label('Ürün Seçiniz')
->options(ProductOrder::query()->where('customer_id', Auth::user()->customer_id)->where('warehouse_status', 1)->pluck('producer', 'id'))
->required(),
TextInput::make('falling_stock')
->label('Çıkılacak Stok Adedi')
->numeric()
->columnSpan([
'md' => 1,
])
->required()
->lazy()
->rule(function ($get) {
}),
Forms\Components\Card::make([
Repeater::make('OrdersItem')->label('Ürünler')
->relationship()
->schema([
Select::make('product_order_id')->label('Ürün Seçiniz')
->options(ProductOrder::query()->where('customer_id', Auth::user()->customer_id)->where('warehouse_status', 1)->pluck('producer', 'id'))
->required(),
TextInput::make('falling_stock')
->label('Çıkılacak Stok Adedi')
->numeric()
->columnSpan([
'md' => 1,
])
->required()
->lazy()
->rule(function ($get) {
}),
but I cannot use it in ProductQuery as $this->barcode_number
Dennis Koch
Dennis Koch2y ago
So is it redirecting now?
Mehmet K.
Mehmet K.OP2y ago
yes it redirects but I can't use it 😄
Dennis Koch
Dennis Koch2y ago
Because it's not a route argument. Use the request helper to get query params
Mehmet K.
Mehmet K.OP2y ago
It's probably not gonna be exactly what I want. Sending more than one query will look ridiculous in the url part and I think it will take quite a while to extract. but thank you for everything.
Dennis Koch
Dennis Koch2y ago
You can still put it in a session. But there are no other ways than "forms" or "query params" to send data between urls
Want results from more Discord servers?
Add your server