sohail
sohail
FFilament
Created by sohail on 1/20/2025 in #❓┊help
`goToWizardStep` is not working in test
Hi i am trying to validate some data in each step of my form wizard but i seem like i can not start the form on the 2nd step as per doc when i use the go to Wizard step i can error saying it still on the first step Ps i dont have skipable steps
it('validates phase dates are in correct order', function () {
livewire(CreateContest::class)
->goToWizardStep(2)
->assertWizardCurrentStep(2);

});
it('validates phase dates are in correct order', function () {
livewire(CreateContest::class)
->goToWizardStep(2)
->assertWizardCurrentStep(2);

});
2 replies
FFilament
Created by sohail on 1/9/2025 in #❓┊help
database notifications conditionally hide mark as unread/read button
I can add those buttons to a notification, but I only want it to be rendered if it is actually needed. If the notification is read. I don't know how I can inject a dependency in the closure, so I can conditionally hide it
->actions([
Action::make('markAsRead')
->button()
->markAsRead(),
Action::make('markAsUnread')
->button()
->markAsUnread(),
])
->actions([
Action::make('markAsRead')
->button()
->markAsRead(),
Action::make('markAsUnread')
->button()
->markAsUnread(),
])
7 replies
FFilament
Created by sohail on 12/25/2024 in #❓┊help
Datepicker return time how to return date only
No description
27 replies
FFilament
Created by sohail on 12/18/2024 in #❓┊help
how to check when an action us canceled
Hi i am writing a action of test of a action the is cancel if some condition are not met my question how to i write test for the for halt() we have assertTableBulkActionHalted but i did find any assertion for cancle
2 replies
FFilament
Created by sohail on 12/18/2024 in #❓┊help
`assertnotified` not working in table action
Hi i a writing a test for table actions and i do see the notification in browser but in test it failed and send notficiation was not send Code
Action::make('toggle_admin_access')
->requiresConfirmation()
->form(ActionForms::confirmationForm())
->successNotificationTitle(fn(User $record) => $record->is_admin ? 'Admin Access Removed Successfully' : 'Admin Access Granted Successfully')
->action(function (User $record, Action $action) {
$record->toggleAdminAccess();
$action->sendSuccessNotification();
});
Action::make('toggle_admin_access')
->requiresConfirmation()
->form(ActionForms::confirmationForm())
->successNotificationTitle(fn(User $record) => $record->is_admin ? 'Admin Access Removed Successfully' : 'Admin Access Granted Successfully')
->action(function (User $record, Action $action) {
$record->toggleAdminAccess();
$action->sendSuccessNotification();
});
Test
it('can grant admin access to user', function () {
$user = User::factory()->create([
'is_admin' => false,
]);
signin('admin');

livewire(Index::class)
->callTableAction('toggle_admin_access', $user, ['confirmations' => 'Confirm'])
->assertHasNoTableActionErrors()
->assertNotified('Admin Access Granted Successfully');

expect($user->fresh())->is_admin->toBeTrue();
});
it('can grant admin access to user', function () {
$user = User::factory()->create([
'is_admin' => false,
]);
signin('admin');

livewire(Index::class)
->callTableAction('toggle_admin_access', $user, ['confirmations' => 'Confirm'])
->assertHasNoTableActionErrors()
->assertNotified('Admin Access Granted Successfully');

expect($user->fresh())->is_admin->toBeTrue();
});
Error
A notification was not sent
Failed asserting that null is not null.
at vendor/filament/notifications/src/Notification.php:259
at vendor/filament/notifications/src/Testing/TestsNotifications.php:20
at vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php:126
at vendor/livewire/livewire/src/Features/SupportTesting/Testable.php:293
A notification was not sent
Failed asserting that null is not null.
at vendor/filament/notifications/src/Notification.php:259
at vendor/filament/notifications/src/Testing/TestsNotifications.php:20
at vendor/laravel/framework/src/Illuminate/Macroable/Traits/Macroable.php:126
at vendor/livewire/livewire/src/Features/SupportTesting/Testable.php:293
2 replies
FFilament
Created by sohail on 12/12/2024 in #❓┊help
how to set the data from input to a form modal
USING FORM & ACTION BUILDER Hi i have a permission tags input and i also have action inside that input the open a modal and from the user can select the permision and the they will see it in tags input i can set the permission to the tags input from the modal but when i open the modal the permission are alway unchecked how can i set the permission form the tags input the the selected permission are checked my code
public function mount()
{
$this->form->fill(['permissions' => 'can:edit', 'can:create'])
}

public function form(Form $form): Form
{
return $form->schema([
TagsInput::make('permissions')
->hintAction(
Action::make('add_permissions')
->form([
CheckboxList::make('permission_name')
->options($this->permissionsNames)
])
->icon('fal-plus')
->action(function (Set $set, $data) {
$set('permissions', [
...$data['permission_name']
]);
})
)
}
#[Computed(persist: true)]
private function permissionsNames(): array
{
return Permission::whereIsGlobal(false)
->pluck('name', 'name')
->toArray();
}
public function mount()
{
$this->form->fill(['permissions' => 'can:edit', 'can:create'])
}

public function form(Form $form): Form
{
return $form->schema([
TagsInput::make('permissions')
->hintAction(
Action::make('add_permissions')
->form([
CheckboxList::make('permission_name')
->options($this->permissionsNames)
])
->icon('fal-plus')
->action(function (Set $set, $data) {
$set('permissions', [
...$data['permission_name']
]);
})
)
}
#[Computed(persist: true)]
private function permissionsNames(): array
{
return Permission::whereIsGlobal(false)
->pluck('name', 'name')
->toArray();
}
2 replies
FFilament
Created by sohail on 12/10/2024 in #❓┊help
Filament Test Fails for Force Delete Action but Works in Browser
I'm testing a ForceDeleteAction for an organization in a Filament table builder Liveware component using Pest. The functionality works perfectly in the browser but fails during the test, with the error:
Failed asserting that a row in the table [organizations] does not match the attributes {
"id": "9db0f9f5-e8b5-4470-9d58-98cb00c76574"
}.
Failed asserting that a row in the table [organizations] does not match the attributes {
"id": "9db0f9f5-e8b5-4470-9d58-98cb00c76574"
}.
Here’s my test code:
it('can permanently delete trashed organization', function () {
$user = User::factory()->create(['email_verified_at' => now()]);
$this->actingAs($user);
$organization = Organization::factory()->trashed()->create();

livewire(Index::class)
->callTableAction(ForceDeleteAction::class, $organization, ['confirmation' => 'Confirm'])
->assertHasNoTableActionErrors();

$this->assertModelMissing($organization);
});
it('can permanently delete trashed organization', function () {
$user = User::factory()->create(['email_verified_at' => now()]);
$this->actingAs($user);
$organization = Organization::factory()->trashed()->create();

livewire(Index::class)
->callTableAction(ForceDeleteAction::class, $organization, ['confirmation' => 'Confirm'])
->assertHasNoTableActionErrors();

$this->assertModelMissing($organization);
});
And here is the ForceDeleteAction implementation:
ForceDeleteAction::make()
->label('Delete Permanently')
->requiresConfirmation()
->icon('fal-trash')
->modalIcon(false)
->modalWidth(MaxWidth::Large)
->modalHeading('Delete Organization')
->modalContent(view('components.confirmation-warning'))
->modalSubmitActionLabel('Yes, Delete Organization')
->successNotificationTitle('Organization has been delete permanently')
->form(Organization::confirmationForm());
ForceDeleteAction::make()
->label('Delete Permanently')
->requiresConfirmation()
->icon('fal-trash')
->modalIcon(false)
->modalWidth(MaxWidth::Large)
->modalHeading('Delete Organization')
->modalContent(view('components.confirmation-warning'))
->modalSubmitActionLabel('Yes, Delete Organization')
->successNotificationTitle('Organization has been delete permanently')
->form(Organization::confirmationForm());
it works in the browser. However, in the test, it appears that the model is still present in the database, causing assertModelMissing to fail. Additional Details: - The Organization model uses soft deletes. - The database has a deleted_at column. - The trashed() state in the factory correctly sets the deleted_at column.
What could cause the action to work in the browser but fail during the test? How can I resolve this discrepancy?
5 replies
FFilament
Created by sohail on 12/9/2024 in #❓┊help
How to Structure Code for Filament Modules in Livewire?
I am using all Filament modules in Livewire directly, not the Panel Builder. My goal to make the main component cleaner and lighter by breaking down functionality into smaller parts. Here are the two approaches I am considering: Approach 1: Using Traits - Break down actions and forms into traits to keep the main Livewire component focused on its primary responsibilities.
- The traits encapsulate logic related to actions and forms for better code clarity.
File Structure:
app/
├── Http/
│ ├── Livewire/
│ │ ├── Organization/
│ │ │ ├── Index.php
│ │ │ ├── Traits/
│ │ │ │ ├── Actions.php
│ │ │ │ ├── Forms.php
app/
├── Http/
│ ├── Livewire/
│ │ ├── Organization/
│ │ │ ├── Index.php
│ │ │ ├── Traits/
│ │ │ │ ├── Actions.php
│ │ │ │ ├── Forms.php
--- Approach 2: Using Classes - Encapsulate each action and bulk action into its own class for better organization.
- The classes are grouped logically in directories to separate concerns and keep the main component light.
File Structure:
app/
├── Http/
│ ├── Livewire/
│ │ ├── Organization/
│ │ │ ├── Index.php
│ │ │ ├── Actions/
│ │ │ │ ├── Edit.php
│ │ │ │ ├── Restore.php
│ │ │ │ ├── Delete.php
│ │ │ │ ├── ForceDelete.php
│ │ │ ├── BulkActions/
│ │ │ │ ├── BulkRestore.php
│ │ │ │ ├── BulkDelete.php
│ │ │ │ ├── BulkForceDelete.php
app/
├── Http/
│ ├── Livewire/
│ │ ├── Organization/
│ │ │ ├── Index.php
│ │ │ ├── Actions/
│ │ │ │ ├── Edit.php
│ │ │ │ ├── Restore.php
│ │ │ │ ├── Delete.php
│ │ │ │ ├── ForceDelete.php
│ │ │ ├── BulkActions/
│ │ │ │ ├── BulkRestore.php
│ │ │ │ ├── BulkDelete.php
│ │ │ │ ├── BulkForceDelete.php
Which approach is more used in the filament Community
5 replies
FFilament
Created by sohail on 12/5/2024 in #❓┊help
Trash Filter Selection & Page selection have white background on Darkmode
Hi i am using filament table builder and for some reason it trash filter select and pagination select have a white background
$table->query(Organization::query())
->heading('All Organizations')
->description('You can manage your organizations here')
->searchPlaceholder('Search For Organizations')
->columns($this->column())
->actions($this->actions())
->bulkActions($this->bulkActions())
->filters([
TrashedFilter::make('trashed')
])
->headerActions([
CreateAction::make()
->label('Create Organization')
->url('/')
]);
$table->query(Organization::query())
->heading('All Organizations')
->description('You can manage your organizations here')
->searchPlaceholder('Search For Organizations')
->columns($this->column())
->actions($this->actions())
->bulkActions($this->bulkActions())
->filters([
TrashedFilter::make('trashed')
])
->headerActions([
CreateAction::make()
->label('Create Organization')
->url('/')
]);
6 replies
FFilament
Created by sohail on 12/4/2024 in #❓┊help
How to add search bar to table Header & and make pagination always visable
Hi is there a way to add search bar to table header and i can i fix the pagination to page bottom so it is always visible to the user
7 replies
FFilament
Created by sohail on 12/3/2024 in #❓┊help
How to use custom icon
No description
21 replies
FFilament
Created by sohail on 9/30/2024 in #❓┊help
Fork the repo but when i installed filament from my forked repo i get a Error
Issue https://github.com/filamentphp/filament/issues/14394 Fix Pull Request https://github.com/filamentphp/filament/compare/3.x...sohailahmad07:filament:add_disable_grammarly Hi to fix the above simple issue i fork the repo and fix it but before i make a pull request i want to test it locally so i installed a fresh laravel project and in my composer.json i add
"require-dev": {
"filament/filament": "dev-add_disable_grammarly",
}
"repositories": [
{
"type": "vcs",
"url": "https://github.com/sohailahmad07/filament"
}
]
"require-dev": {
"filament/filament": "dev-add_disable_grammarly",
}
"repositories": [
{
"type": "vcs",
"url": "https://github.com/sohailahmad07/filament"
}
]
but when run composer install i get the error
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
Script Illuminate\Foundation\ComposerScripts::postAutoloadDump handling the post-autoload-dump event terminated with an exception

In autoload_real.php line 41:

require(/mnt/DevOps/devops/Open-Source/Testing-Filament/vendor/composer/../filament/filament/tests/helpers.php): Failed to open stream: No such file or directory

install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] ...
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
Script Illuminate\Foundation\ComposerScripts::postAutoloadDump handling the post-autoload-dump event terminated with an exception

In autoload_real.php line 41:

require(/mnt/DevOps/devops/Open-Source/Testing-Filament/vendor/composer/../filament/filament/tests/helpers.php): Failed to open stream: No such file or directory

install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] ...
and i a positive i did not create this issue so i create a new branch for 3.x (default) and with out any change i push that branch and when i tried to installed form that brand i get the same error
2 replies