JJSanders
JJSanders
FFilament
Created by JJSanders on 9/30/2024 in #❓┊help
addAction function called on page load
When I have a repeater with an addAction function. When I load the page with the repeater on it the addAction code is executed. I would expect this to be called only when pressing the action button.
->addAction(function ($livewire, $component) { dump('test');})
->addAction(function ($livewire, $component) { dump('test');})
Any suggestions? Thanks.
7 replies
FFilament
Created by JJSanders on 7/24/2024 in #❓┊help
Collapse navigation when on specific page
Does anyone know if it is possible to Collapse the navigation only when on a certain resource page?
8 replies
FFilament
Created by JJSanders on 7/15/2024 in #❓┊help
Testing a form action.
Hey, I have the following action on my ListUsers field:
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
Actions\Action::make('nodigGebruikerUit')
->form([
TextInput::make('email')
->email()
->required()
])
->action(function ($data) {
$invitation = Invitation::create(['email' => $data['email']]);

Mail::to($invitation->email)->send(new TeamInvitationMail($invitation));

Notification::make('invitedSuccess')
->body('De gebruiker is uitgenodigd')
->success()->send();
})
];
}
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
Actions\Action::make('nodigGebruikerUit')
->form([
TextInput::make('email')
->email()
->required()
])
->action(function ($data) {
$invitation = Invitation::create(['email' => $data['email']]);

Mail::to($invitation->email)->send(new TeamInvitationMail($invitation));

Notification::make('invitedSuccess')
->body('De gebruiker is uitgenodigd')
->success()->send();
})
];
}
Now I am trying to write a test:
it('sends an email when the button is pushed', function () {
login(); //don't mind this it's my own helper function
Mail::fake();

livewire(ListUsers::class)
->callAction('nodigGebruikerUit')
->callAction('send', ['email', '[email protected]']);


Mail::assertSent(TeamInvitationMail::class, function($mail) {
return $mail->hasTo('[email protected]');
});

});
it('sends an email when the button is pushed', function () {
login(); //don't mind this it's my own helper function
Mail::fake();

livewire(ListUsers::class)
->callAction('nodigGebruikerUit')
->callAction('send', ['email', '[email protected]']);


Mail::assertSent(TeamInvitationMail::class, function($mail) {
return $mail->hasTo('[email protected]');
});

});
I am getting an error: failed asserting an action with the name [send] exists. I am not sure how to continue. I have a button, when I press that button a form loads and I want to test that when I press that button, en email is sent. Thanks for your help.
21 replies
FFilament
Created by JJSanders on 7/4/2024 in #❓┊help
Search in a specific column
Hello, I am wondering if it is possible, be it in the global search or in the search of the table to search in a specific column? For example I would like to search for "foo" but only in the reference column? Thanks
6 replies
FFilament
Created by JJSanders on 6/23/2024 in #❓┊help
Custom action modal
Hello, I have got the following question. I have created a custom action. The action gennerally doesn't need a modal. But sometimes the action does need a model which should then show a form in the modal where the user should fill out some input (this needs to be validated etc) I can't figure out how to show the modal conditionally. My code at the moment looks like this:
Actions\Action::make('Connect ingredients')
->action(function(Product $product){
//(... removed some code for simplicity)
$decider->decide();
$product->fresh();
if ($decider->getMessages()) {
// Here I want to show a modal with a custom form etc.
}

Notification::make()
->title('Sucessfull')
->color('success')
->send();
})
];
Actions\Action::make('Connect ingredients')
->action(function(Product $product){
//(... removed some code for simplicity)
$decider->decide();
$product->fresh();
if ($decider->getMessages()) {
// Here I want to show a modal with a custom form etc.
}

Notification::make()
->title('Sucessfull')
->color('success')
->send();
})
];
Can Anyone guide me in the right direction? Thanks !
9 replies
FFilament
Created by JJSanders on 6/4/2024 in #❓┊help
Testing a TextInputColumn
Given I have a TextInputColumn. I want to test inputing values and other behaviour. Given I have TextInputColumn::make('amountOrdered')->label('ordered'), Now I want to write some tests around this. So I tried:
livewire(OrderItemResource\Pages\ListOrderItems::class)
->set('amountOrdered' , 1);
livewire(OrderItemResource\Pages\ListOrderItems::class)
->set('amountOrdered' , 1);
However this gives me an error:
FAILED Tests\Feature\OrderItemTest > it can propperly increase and decrease the product stock PublicPropertyNotFoundException
Unable to set component data. Public property [$amountOrdered] not found on component: [app.filament.resources.order-item-resource.pages.list-order-items]
FAILED Tests\Feature\OrderItemTest > it can propperly increase and decrease the product stock PublicPropertyNotFoundException
Unable to set component data. Public property [$amountOrdered] not found on component: [app.filament.resources.order-item-resource.pages.list-order-items]
Any suggestions?
13 replies
FFilament
Created by JJSanders on 6/3/2024 in #❓┊help
Use `cloneAction` to only clone one column
How can i use the cloneAction method to only clone for example the product_id and not the amount ordered in a repeater? I am trying to figure it out from here: https://filamentphp.com/docs/3.x/forms/fields/repeater#cloning-items It accepts a closure but I am not sure how to work out the closure. I am stuck here:
->cloneable()
->cloneAction(fn (Action $action) => tap($action, fn ($action) => ray($action)))
->cloneable()
->cloneAction(fn (Action $action) => tap($action, fn ($action) => ray($action)))
Thanks
4 replies
FFilament
Created by JJSanders on 5/29/2024 in #❓┊help
Uncaught Snapshot missing on Livewire component with id: QAcNIGM0wsdXZxTaZYW7
Hello, I have a widget on the dashboard panel and I run into this error:
livewire.js?id=07f22875:4496 Uncaught Snapshot missing on Livewire component with id: 46aAsyAJRQmsahOifnDD
livewire.js?id=07f22875:4496 Uncaught Snapshot missing on Livewire component with id: 46aAsyAJRQmsahOifnDD
I have logged a few lines in livewire.js
var Component = class {
constructor(el) {
if (el.__livewire)
throw "Component already initialized";
el.__livewire = this;
this.el = el;
this.id = el.getAttribute("wire:id");
this.__livewireId = this.id;

// Log the component ID and element
console.log('Initializing component with ID:', this.id);
console.log('Element:', this.el);

this.snapshotEncoded = el.getAttribute("wire:snapshot");
this.snapshot = JSON.parse(this.snapshotEncoded);
if (!this.snapshot) {
throw `Snapshot missing on Livewire component with id: ` + this.id;
}
var Component = class {
constructor(el) {
if (el.__livewire)
throw "Component already initialized";
el.__livewire = this;
this.el = el;
this.id = el.getAttribute("wire:id");
this.__livewireId = this.id;

// Log the component ID and element
console.log('Initializing component with ID:', this.id);
console.log('Element:', this.el);

this.snapshotEncoded = el.getAttribute("wire:snapshot");
this.snapshot = JSON.parse(this.snapshotEncoded);
if (!this.snapshot) {
throw `Snapshot missing on Livewire component with id: ` + this.id;
}
This gives me the following output:
Initializing component with ID: RrX3NJt5ITldClnRMXfS
livewire.js?id=07f22875:4491 Element: <div wire:snapshot=​"{"data":​{"isFilamentNotificationsComponent":​true,"notifications":​[[]​,{"class":​"Filament\\Notifications\\Collection","s":​"wrbl"}​]​}​,"memo":​{"id":​"RrX3NJt5ITldClnRMXfS","name":​"filament.livewire.notifications","path":​"admin","method":​"GET","children":​[]​,"scripts":​[]​,"assets":​[]​,"errors":​[]​,"locale":​"en"}​,"checksum":​"490cc37887409efc358c5334492120673db2dd7f97d9bca91b0c9dd3fed92a5c"}​" wire:effects=​"{"listeners":​["notificationsSent","notificationSent","notificationClosed"]​}​" wire:id=​"RrX3NJt5ITldClnRMXfS">​…​</div>​
livewire.js?id=07f22875:4490 Initializing component with ID: QAcNIGM0wsdXZxTaZYW7
livewire.js?id=07f22875:4491 Element: <div wire:id=​"QAcNIGM0wsdXZxTaZYW7" wire:poll.5s class=​"fi-wi-stats-overview-stats-ctn grid gap-6 md:​grid-cols-3">​…​</div>​grid
Initializing component with ID: RrX3NJt5ITldClnRMXfS
livewire.js?id=07f22875:4491 Element: <div wire:snapshot=​"{"data":​{"isFilamentNotificationsComponent":​true,"notifications":​[[]​,{"class":​"Filament\\Notifications\\Collection","s":​"wrbl"}​]​}​,"memo":​{"id":​"RrX3NJt5ITldClnRMXfS","name":​"filament.livewire.notifications","path":​"admin","method":​"GET","children":​[]​,"scripts":​[]​,"assets":​[]​,"errors":​[]​,"locale":​"en"}​,"checksum":​"490cc37887409efc358c5334492120673db2dd7f97d9bca91b0c9dd3fed92a5c"}​" wire:effects=​"{"listeners":​["notificationsSent","notificationSent","notificationClosed"]​}​" wire:id=​"RrX3NJt5ITldClnRMXfS">​…​</div>​
livewire.js?id=07f22875:4490 Initializing component with ID: QAcNIGM0wsdXZxTaZYW7
livewire.js?id=07f22875:4491 Element: <div wire:id=​"QAcNIGM0wsdXZxTaZYW7" wire:poll.5s class=​"fi-wi-stats-overview-stats-ctn grid gap-6 md:​grid-cols-3">​…​</div>​grid
I am not sure how to solve this. I would like to welcome some suggestions. Thanks
67 replies
FFilament
Created by JJSanders on 5/23/2024 in #❓┊help
Action causes error: TypeError: Cannot convert undefined or null to object
No description
3 replies
FFilament
Created by JJSanders on 5/21/2024 in #❓┊help
Stop job from executing
Hello, My errorlog keeps filling up with these errors: How can I stop them from being executed over and over again. I am running on redis. I have set the tries to: 'tries' => 3 on production. But it keeps coming back and have no idea how to stop it. Any suggestions?
2 replies
FFilament
Created by JJSanders on 5/21/2024 in #❓┊help
Small documentation page
Hello everyone, I was asked by my client to build a page / popup where the admin can write some usage instructions for the application and the users can read this instructions. It doesn't need to be sophisticated it can be just a HTML field which is then represented to the end user as html. Before I decide to build this myself, I was wondering if there is already a plugin for this .
9 replies
FFilament
Created by JJSanders on 5/19/2024 in #❓┊help
Show table row action only when filter is enabled
Hey all, Is it possible to hide an action in the table when a filter is not enabled?
8 replies
FFilament
Created by JJSanders on 5/14/2024 in #❓┊help
Avoid duplicate code
Good morning, Lets say I have two resources: -> Brands -> Ingredients Both have a relation with products. So for both resources I have separate a relationmanager to products. Both relationmanagers have a table with the same code for table. My question is how what are ways to abstract this code so that I only have the tableoverview for products once? Thanks.
6 replies
FFilament
Created by JJSanders on 5/13/2024 in #❓┊help
Code field in Filament
No description
6 replies
FFilament
Created by JJSanders on 5/12/2024 in #❓┊help
infolist label position
Hello, Is it possible to change the position of a label on the infolist?
5 replies
FFilament
Created by JJSanders on 4/3/2024 in #❓┊help
TextEntry when value is null
TextEntry::make('strap')
->columnSpanFull()
->getStateUsing(function (Product $record) {
ray($record);
return $record->strap === 1 ? 'Ja' : 'Nee';
})
TextEntry::make('strap')
->columnSpanFull()
->getStateUsing(function (Product $record) {
ray($record);
return $record->strap === 1 ? 'Ja' : 'Nee';
})
Why doesn't this work when the value of strap is null?
9 replies
FFilament
Created by JJSanders on 3/4/2024 in #❓┊help
Change layout in a modal form
->form([
Select::make('order_id')
->options(function (?Product $product) {
return Order::select('id', DB::raw('CONCAT(\'Openstaande order van \', DATE_FORMAT(created_at, "%d-%m-%Y")) as concatenated_value'))
->where('brand_id', $product->brand_id)
->where('sent', false)
->whereNull('deleted_at')
->pluck('concatenated_value', 'id')
->toArray();
})
->label('Order')
->searchable()
->preload()
->columnSpan(3)
->required(),
Select::make('type')
->label('Type')
->required()
->options(OrderGoal::class),
TextInput::make('quantity')
->numeric()
->label('Aantal')
->required(),
TextInput::make('reference')
->label('Referentienummer'),
TextInput::make('remarks')
->label('Opmerkingen'),
]),
->form([
Select::make('order_id')
->options(function (?Product $product) {
return Order::select('id', DB::raw('CONCAT(\'Openstaande order van \', DATE_FORMAT(created_at, "%d-%m-%Y")) as concatenated_value'))
->where('brand_id', $product->brand_id)
->where('sent', false)
->whereNull('deleted_at')
->pluck('concatenated_value', 'id')
->toArray();
})
->label('Order')
->searchable()
->preload()
->columnSpan(3)
->required(),
Select::make('type')
->label('Type')
->required()
->options(OrderGoal::class),
TextInput::make('quantity')
->numeric()
->label('Aantal')
->required(),
TextInput::make('reference')
->label('Referentienummer'),
TextInput::make('remarks')
->label('Opmerkingen'),
]),
I would like to split the last to inputs evenly on the bottom row. But I can't find how to fix layout in a modal. Any suggestions?
6 replies
FFilament
Created by JJSanders on 2/29/2024 in #❓┊help
Select automatically select the first one
Hello, Given this example:
Select::make('author_id')
->label('Author')
->options(User::all()->pluck('name', 'id'))
->searchable()
Select::make('author_id')
->label('Author')
->options(User::all()->pluck('name', 'id'))
->searchable()
In case there is only one user. Is it possible to automatically set the value of the select to that user? Thanks .
5 replies
FFilament
Created by JJSanders on 2/29/2024 in #❓┊help
Set the title of an action form
Hello, I have an action which opens a form in a modal. Is it possible to set the title of the form or the formheading
4 replies
FFilament
Created by JJSanders on 2/26/2024 in #❓┊help
Set the label of a select using $set
In my code I have
->afterStateUpdated(function($state, Set $set) {
if (is_array($state)) {
$set('product_id', $state['id']);
}
})
->afterStateUpdated(function($state, Set $set) {
if (is_array($state)) {
$set('product_id', $state['id']);
}
})
This code sets the value of my Select after a new item has been added using a CreateOptionForm. This succesfully sets the value of the Select. Does anyone know if it is possible to also set the label of the select somehow using the $set method? Thanks
13 replies