Pedroesca
Pedroesca
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