Pedroesca
Pedroesca
FFilament
Created by Pedroesca on 1/21/2025 in #❓┊help
Halt reload table
When an action is executed within the table, it is reloaded. Is it possible to skip that automatic reload after the action?
3 replies
FFilament
Created by Pedroesca on 12/24/2024 in #❓┊help
Custom search in table
I have a little situation here: When I get ONLY ONE record, I need to add it to the cart (that happens, I just have to refresh the page with F5 for it to be reflected); When I search by other criteria, it gets them correctly but when I press the action row, IT ALWAYS ADDS THE FIRST record in the table. I know I'm doing something wrong. public function table(Table $table): Table { return $table ->query(function() { if ($this->tableSearch === '') { return Product::query()->whereRaw('1 = 0'); } else { $product = Product::get() ->where('barcode', '=', $this->tableSearch); if ($product->count() === 1) { $this->addToCart($product->first()->id); $this->updateCart(); $this->resetTableSearch(); return Product::query()->whereRaw('1 = 0'); } else { return Product::query() ->where('name', 'like', '%' . $this->tableSearch . '%') ->orWhere('barcode', 'like', '%' . $this->tableSearch . '%'); } } return Product::query(); }) ->columns([ TextColumn::make('name')->searchable(), TextColumn::make('barcode')->searchable(), ]) ->actions([ Action::make('add-cart') ->button() ->action(function($record){ $this->addToCart($record->id); //dd($record); }) ]); }
1 replies
FFilament
Created by Pedroesca on 12/24/2024 in #❓┊help
passing data between forms
I have two forms, headerData and footerData. Is it possible to pass data from header to footer? Or what would be the same, get data from a field in header in footer?
7 replies
FFilament
Created by Pedroesca on 12/19/2024 in #❓┊help
Reset input search
No description
3 replies
FFilament
Created by Pedroesca on 12/17/2024 in #❓┊help
Searchable in select blade
Hola. Es posible que al blade del select: <x-filament::input.wrapper> <x-filament::input.select wire:model="status"> <option value="draft">Draft</option> <option value="reviewing">Reviewing</option> <option value="published">Published</option> </x-filament::input.select> </x-filament::input.wrapper> se le pueda agregar la propiedad o método "searchable()" tal como se utiliza en un recurso de filament?
2 replies
FFilament
Created by Pedroesca on 9/19/2024 in #❓┊help
Action on click row table
When clicking on a record in the table, it performs a default action, okay? So, how can I perform one action or another depending on the state of a certain field?
3 replies
FFilament
Created by Pedroesca on 9/6/2024 in #❓┊help
Profile Page
Can I freely modify <app>\vendor\filament\filament\src\Pages\Auth\EditProfile.php ? won't it be affected when I update to other filament versions? ?
5 replies
FFilament
Created by Pedroesca on 9/3/2024 in #❓┊help
beforeSave whith relations
I have the following process in beforeSave() of EditSale.php, in which I restore the stock (quantities) of products, before the records are saved, as indicated by the "beforeSave" hook, but it turns out that when entering this hook the data of the relationship (SaleDetails) has already been saved.
protected function beforeSave(): void
{
//antes de guardar, DESHACEMOS EL STOCK
$originalDetails = $this->record->products->map(function($product) {
return [
'product_id' => $product->id,
'qty' => $product->getOriginal('qty'), // Obtener la cantidad original antes de la modificación
];
});
dd($originalDetails);
foreach ($originalDetails as $detail) {
$product = $detail->product;
Log::info('revert stock', ['product_id' => $product->id]);
Log::info('revert stock', ['cant anterior' => $detail->qty]);
Log::info('revert stock', ['stock anterior' => $product->stock_current]);
$product->stock_current += $detail->qty;
$product->save();
}

}
protected function beforeSave(): void
{
//antes de guardar, DESHACEMOS EL STOCK
$originalDetails = $this->record->products->map(function($product) {
return [
'product_id' => $product->id,
'qty' => $product->getOriginal('qty'), // Obtener la cantidad original antes de la modificación
];
});
dd($originalDetails);
foreach ($originalDetails as $detail) {
$product = $detail->product;
Log::info('revert stock', ['product_id' => $product->id]);
Log::info('revert stock', ['cant anterior' => $detail->qty]);
Log::info('revert stock', ['stock anterior' => $product->stock_current]);
$product->stock_current += $detail->qty;
$product->save();
}

}
i.e. where do i get the original detail before it is saved? is there a hook for this? for these cases beforesave does not work.
11 replies
FFilament
Created by Pedroesca on 8/23/2024 in #❓┊help
Infolist in modal
No description
1 replies
FFilament
Created by Pedroesca on 8/18/2024 in #❓┊help
Layout modification
No description
6 replies
FFilament
Created by Pedroesca on 6/6/2024 in #❓┊help
Only table
Hello everyone. Can I generate a complete resource just to display the table (list) with filters, removing the create, edit and delete actions? Or is it more convenient to generate a custom view with just the table?
5 replies