The Huntsman
The Huntsman
FFilament
Created by The Huntsman on 12/5/2023 in #❓┊help
Mutate form data before create but for delete
Here's the code if anyone else is interested
Actions\DeleteAction::make()
->before(function (Model $record) {
$inventory_id = $record['inventory_id'];
$amount = $record['stock_issued'];
$stock = DB::table('inventories')->where('id', $inventory_id)->value('stock');
$qb = DB::table('inventories')->where('id', $inventory_id)->update(['stock' => $stock + $amount]);
if ($qb == true) {
Notification::make()
->success()
->title('Inventory Updated.')
->send();
} else {
Notification::make()
->warning()
->title('Error')
->body('There was a problem updating inventory.')
->send();
$this->halt();
}
}),
Actions\DeleteAction::make()
->before(function (Model $record) {
$inventory_id = $record['inventory_id'];
$amount = $record['stock_issued'];
$stock = DB::table('inventories')->where('id', $inventory_id)->value('stock');
$qb = DB::table('inventories')->where('id', $inventory_id)->update(['stock' => $stock + $amount]);
if ($qb == true) {
Notification::make()
->success()
->title('Inventory Updated.')
->send();
} else {
Notification::make()
->warning()
->title('Error')
->body('There was a problem updating inventory.')
->send();
$this->halt();
}
}),
12 replies
FFilament
Created by The Huntsman on 12/5/2023 in #❓┊help
Mutate form data before create but for delete
Yup That works, Thank You.
12 replies
FFilament
Created by The Huntsman on 12/5/2023 in #❓┊help
Mutate form data before create but for delete
is it possible for that function to get the data of the record about to be be deleted, like the $data array for mutateFormDataBeforeCreate()
12 replies
FFilament
Created by The Huntsman on 12/5/2023 in #❓┊help
Mutate form data before create but for delete
what about the after() and before() methods that's available on the delete action ? https://filamentphp.com/docs/3.x/actions/prebuilt-actions/delete#lifecycle-hooks
12 replies
FFilament
Created by The Huntsman on 12/4/2023 in #❓┊help
Mutate Before Create Function
well I'm dumb, sorry for wasting your time. it works, Thanks
5 replies
FFilament
Created by The Huntsman on 10/15/2023 in #❓┊help
Using dot to load related data
Yup that worked, thanks, I thought it was <table>.<attribute> my bad
9 replies
FFilament
Created by The Huntsman on 10/15/2023 in #❓┊help
Using dot to load related data
you mean make another relationship for relationship2 in the model file right?
9 replies
FFilament
Created by The Huntsman on 10/11/2023 in #❓┊help
search for foreign key using multiple columns

public static function form(Form $form): Form
{
return $form
->schema([
Select::make('inventory_id')
->searchable()
->getSearchResultsUsing(fn (string $search): array => Inventory::where('productName', 'barcode', 'partNumber', "%{$search}%")->limit(50)->pluck('productName','id')->toArray())
->getOptionLabelsUsing(fn ($value): ?string => Inventory::find($value)?->productName),
]);
}

public static function form(Form $form): Form
{
return $form
->schema([
Select::make('inventory_id')
->searchable()
->getSearchResultsUsing(fn (string $search): array => Inventory::where('productName', 'barcode', 'partNumber', "%{$search}%")->limit(50)->pluck('productName','id')->toArray())
->getOptionLabelsUsing(fn ($value): ?string => Inventory::find($value)?->productName),
]);
}
I tried it and I'm getting this error when searching: https://flareapp.io/share/W7zD2QAm
7 replies
FFilament
Created by The Huntsman on 10/11/2023 in #❓┊help
search for foreign key using multiple columns
public static function form(Form $form): Form { return $form ->schema([ Select::make('inventory_id') ->searchable() ->getSearchResultsUsing(fn (string $search): array => Inventory::where('productName', 'barcode', 'partNumber', "%{$search}%")->limit(50)->pluck('productName','id')->toArray()) ->getOptionLabelsUsing(fn ($value): ?string => Inventory::find($value)?->productName), ]); }
7 replies
FFilament
Created by The Huntsman on 10/11/2023 in #❓┊help
search for foreign key using multiple columns
or at least to search using the barcode and to show the name of the product after selecting the barcode
7 replies
FFilament
Created by The Huntsman on 10/4/2023 in #❓┊help
Array to String
Please ensure that any pivot attributes are listed in the withPivot() method of the relationship and inverse relationship.
So does that mean I have to list all pivot table columns using the withPivot() method? Also that part of the documentation is very uninformative 😥
8 replies
FFilament
Created by The Huntsman on 10/4/2023 in #❓┊help
Array to String
how would I check? that I'm new to this , this is what's in the request body:
"updates": {
"data.eid": "000000001",
"data.contact_number": "+971500000000",
"data.position": "Systems Administrator",
"data.active": true,
"data.employee_department.dept_id": "1",
"data.employee_department.supervisor": true
},
"calls": [
{
"path": null,
"method": "create",
"params": []
"updates": {
"data.eid": "000000001",
"data.contact_number": "+971500000000",
"data.position": "Systems Administrator",
"data.active": true,
"data.employee_department.dept_id": "1",
"data.employee_department.supervisor": true
},
"calls": [
{
"path": null,
"method": "create",
"params": []
8 replies
FFilament
Created by The Huntsman on 10/4/2023 in #❓┊help
Array to String
my bad sorry about that.
8 replies
FFilament
Created by The Huntsman on 10/2/2023 in #❓┊help
Add data to two tables from one form
No description
7 replies
FFilament
Created by The Huntsman on 10/2/2023 in #❓┊help
Add data to two tables from one form
I would also like to point out that I'd like to select the department using the department name instead of the ID
7 replies
FFilament
Created by The Huntsman on 10/1/2023 in #❓┊help
Categories
alright, thanks guys
7 replies
FFilament
Created by The Huntsman on 10/1/2023 in #❓┊help
Categories
No description
7 replies
FFilament
Created by The Huntsman on 9/27/2023 in #❓┊help
images are not showing up in table
okay I found out from stackoverflow that the issue was with the symlink to the the storage folder. had to run, composer require symfony/filesystem then delete the current storage symlink and run, php artisan storage:link --relative which worked, anyhow thanks everyone.
14 replies
FFilament
Created by The Huntsman on 9/27/2023 in #❓┊help
images are not showing up in table
No description
14 replies
FFilament
Created by The Huntsman on 9/27/2023 in #❓┊help
images are not showing up in table
No description
14 replies