Nathan
Nathan
FFilament
Created by Nathan on 8/20/2024 in #❓┊help
Import prevent duplicates
Is there a way to check for duplicates in a CSV import? The validations in https://filamentphp.com/docs/3.x/actions/prebuilt-actions/import are per row, is there a way to check does a certain column contain duplicates and if yes prevent the whole import?
2 replies
FFilament
Created by Nathan on 8/20/2024 in #❓┊help
Is there a way to hide the whole navigation panel depending on role?
One role in a system i am building is supposed to have access only to a single page so, they would like the whole nav panel not to show as it makes no sense. Is there a way to accomplish this?
12 replies
FFilament
Created by Nathan on 5/8/2024 in #❓┊help
Changing colours on standalone Form Builder without Panels
How can i change the default colours when using filament forms without panels. I tried adding this to the boot method of service provider, but nothing changes:
public function boot(): void
{
FilamentColor::register([
'danger' => Color::Red,
'gray' => Color::Zinc,
'info' => Color::Blue,
'primary' => Color::Fuchsia,
'success' => Color::Green,
'warning' => Color::Amber,
]);
}
public function boot(): void
{
FilamentColor::register([
'danger' => Color::Red,
'gray' => Color::Zinc,
'info' => Color::Blue,
'primary' => Color::Fuchsia,
'success' => Color::Green,
'warning' => Color::Amber,
]);
}
6 replies
FFilament
Created by Nathan on 2/22/2024 in #❓┊help
SpatieMediaLibraryFileUpload inside action how to attach to new model
I have an Order Resource in infolist i have an action that creates a payment record attached to current order, but when i added SpatieMediaLibraryFileUpload field to this form it saves the image on the order instead of the payment. Is there a way to tell it to attach to the newly created payment record. Here is my code:
Action::make('addPayment')
->icon('heroicon-m-plus')
->iconButton()
->form([
Grid::make(2)
->schema([
TextInput::make('amount')
->label('Amount')
->prefix('$')
->numeric()
->required(),
DatePicker::make('created_at')
->label('Date')
->default(now())
->required(),
Select::make('payment_method')
->label('Payment Method')
->options(PaymentMethod::toArray())
->required(),
TextInput::make('payment_ref_number')
->label('Reference Number'),
Textarea::make('payment_memo')
->columnSpanFull()
->label('Memo')
->rows(2),
SpatieMediaLibraryFileUpload::make('attachments')
->appendFiles()
->openable()
->collection('resource_files')
->multiple()
->reorderable(),
])
])
->action(function (Order $record, array $data) {
$payment = $record
->payments()
->create([
'amount' => $data['amount'],
'payment_method' => $data['payment_method'],
'payment_ref_number' => $data['payment_ref_number'],
'payment_memo' => $data['payment_memo'],
'created_at' => $data['created_at'],
]);

Notification::make()
->title('Payment Added')
->success()
->send();
})
Action::make('addPayment')
->icon('heroicon-m-plus')
->iconButton()
->form([
Grid::make(2)
->schema([
TextInput::make('amount')
->label('Amount')
->prefix('$')
->numeric()
->required(),
DatePicker::make('created_at')
->label('Date')
->default(now())
->required(),
Select::make('payment_method')
->label('Payment Method')
->options(PaymentMethod::toArray())
->required(),
TextInput::make('payment_ref_number')
->label('Reference Number'),
Textarea::make('payment_memo')
->columnSpanFull()
->label('Memo')
->rows(2),
SpatieMediaLibraryFileUpload::make('attachments')
->appendFiles()
->openable()
->collection('resource_files')
->multiple()
->reorderable(),
])
])
->action(function (Order $record, array $data) {
$payment = $record
->payments()
->create([
'amount' => $data['amount'],
'payment_method' => $data['payment_method'],
'payment_ref_number' => $data['payment_ref_number'],
'payment_memo' => $data['payment_memo'],
'created_at' => $data['created_at'],
]);

Notification::make()
->title('Payment Added')
->success()
->send();
})
4 replies
FFilament
Created by Nathan on 1/26/2024 in #❓┊help
How to handle Error in beforeReplicaSaved
I need to sync with an external API when a new product is created. How can i return an error and stop the replication in the beforeReplicaSaved method if the API call failed? I tried:
Notification::make()
->title('Error')
->body('Item not duplicated')
->send();

$this->redirect(ProductResource::getUrl('view', ['record' => $record]));
Notification::make()
->title('Error')
->body('Item not duplicated')
->send();

$this->redirect(ProductResource::getUrl('view', ['record' => $record]));
But this resulted in 2 messages one error and one success.
2 replies
FFilament
Created by Nathan on 1/7/2024 in #❓┊help
Is there a way to make database notifications play sound for the $recipient?
A client is asking me to add a sound whenever he receives a database notification. How can this be achieved?
11 replies