The Huntsman
The Huntsman
FFilament
Created by The Huntsman on 12/5/2023 in #❓┊help
Mutate form data before create but for delete
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['date_issued'] = date(now());
$amount = $data['stock_issued'];
$stock = DB::table('inventories')->where('id', $data['inventory_id'])->value('stock');
if ($amount > $stock) {
Notification::make()
->warning()
->title('You don\'t have enough Stock!!!')
->body('Only ' . $stock . ' in inventory.')
->send();
$this->halt();
} else {
DB::table('inventories')->where('id', $data['inventory_id'])->update(['stock' => $stock - $amount]);
}
return $data;
}
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['date_issued'] = date(now());
$amount = $data['stock_issued'];
$stock = DB::table('inventories')->where('id', $data['inventory_id'])->value('stock');
if ($amount > $stock) {
Notification::make()
->warning()
->title('You don\'t have enough Stock!!!')
->body('Only ' . $stock . ' in inventory.')
->send();
$this->halt();
} else {
DB::table('inventories')->where('id', $data['inventory_id'])->update(['stock' => $stock - $amount]);
}
return $data;
}
I use the above code to update the inventory when inventory is issued out, I was wondering if there is a function like this but for the delete button so I can undo the inventory update if a record from issued inventory is deleted.
12 replies
FFilament
Created by The Huntsman on 12/4/2023 in #❓┊help
Mutate Before Create Function
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['date_issued'] = date(now());
return $data;
$amount = $data['stock_issued'];
$stock = 10;
if ($amount > $stock) {
Notification::make()
->warning()
->title('You don\'t have enough Stock!!!')
->body('Only ' . $stock . ' in inventory.')
->send();
$this->halt();
}
}
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['date_issued'] = date(now());
return $data;
$amount = $data['stock_issued'];
$stock = 10;
if ($amount > $stock) {
Notification::make()
->warning()
->title('You don\'t have enough Stock!!!')
->body('Only ' . $stock . ' in inventory.')
->send();
$this->halt();
}
}
Can anyone please tell me what's wrong here, I don't get any errors but it doesn't work, and I tried to use the beforeCreate() Function but that doesn't let me pass the $data array.
5 replies
FFilament
Created by The Huntsman on 10/15/2023 in #❓┊help
Using dot to load related data
I have a table with two foreign keys that are from the same table, how do I make that work
->columns([
TextColumn::make('employees.name')
->label('Issued By'),
TextColumn::make('employees.name')
->label('Issued To'),
])
->columns([
TextColumn::make('employees.name')
->label('Issued By'),
TextColumn::make('employees.name')
->label('Issued To'),
])
this just makes one column disappear can anyone help?
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')
->relationship('inventory', 'productName')
->relationship('inventory', 'barcode')
->relationship('inventory', 'partNumber')
->searchable()

]);
}
public static function form(Form $form): Form
{
return $form
->schema([
Select::make('inventory_id')
->relationship('inventory', 'productName')
->relationship('inventory', 'barcode')
->relationship('inventory', 'partNumber')
->searchable()

]);
}
hey all can anyone tell me how to make this work?
7 replies
FFilament
Created by The Huntsman on 10/11/2023 in #❓┊help
Enlarge image in table on hover
is there a way to make the image column bigger on hover?
4 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
Why does 's' get added to end of my resources?
No description
4 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
No description
14 replies
FFilament
Created by The Huntsman on 9/25/2023 in #❓┊help
First install I'm getting an error after clicking login
No description
4 replies