slakkie
slakkie
FFilament
Created by PabloZagni on 8/4/2024 in #❓┊help
How to refresh a relationManager after Action on Owner.
13 replies
FFilament
Created by kennyhorna on 8/11/2024 in #❓┊help
How to re-render/refresh the parent form after a new entry of a RelationManager has been created?
Hey no worries, thanks for all your help! It's really quite a draw-back that there is not comms between some components. It goes against logic 🙂 I've settled on refreshing the page:
->action(function (Event $record, StaticAction $action, $livewire) {
app()->make('cart')->addEvent($record->id);
$action->redirect(request()->header('Referer'));
->action(function (Event $record, StaticAction $action, $livewire) {
app()->make('cart')->addEvent($record->id);
$action->redirect(request()->header('Referer'));
Again thanks for you help!!
18 replies
FFilament
Created by PabloZagni on 8/4/2024 in #❓┊help
How to refresh a relationManager after Action on Owner.
Hey @Dennis Koch thanks again for all the help. Seems like the badge just takes in a string it is not Htmlable, which would mean I need to override: resource\views\component\sidenav\item.blade.php ... and that is of course not optimal. I think for now I am going to settle on this non-optimal way:
->action(function (Event $record, StaticAction $action, $livewire) {
app()->make('cart')->addEvent($record->id);
$action->redirect(request()->header('Referer'));
->action(function (Event $record, StaticAction $action, $livewire) {
app()->make('cart')->addEvent($record->id);
$action->redirect(request()->header('Referer'));
Again thanks for the help!! Hopefully it's something that will be easier in the future.
13 replies
FFilament
Created by PabloZagni on 8/4/2024 in #❓┊help
How to refresh a relationManager after Action on Owner.
interesting ok going to give that a shot on the method in the Page which gets the count:
public static function getNavigationBadge(): ?string
{
return static::refreshBadgeCount();
}
public static function getNavigationBadge(): ?string
{
return static::refreshBadgeCount();
}
Just for interest sake on: https://filamentphp.com/docs/3.x/notifications/sending-notifications#dispatching-livewire-events-from-notification-actions There is a method on the notifications component, which can do:
->dispatchTo('another_component', 'undoEditingPost', [$post->id])
->dispatchTo('another_component', 'undoEditingPost', [$post->id])
So when I bring in the $action that method also exists on it for example:
->action(function (Event $record, StaticAction $action, $livewire) {

$action->dispatchTo('app.filament.resources.pages.cart', 'updated_cart');
->action(function (Event $record, StaticAction $action, $livewire) {

$action->dispatchTo('app.filament.resources.pages.cart', 'updated_cart');
But not sure yet how that works and what the name is of the component I just pulled that name with the getName() method of the Cart component. Anyway will quickly try that Alpine way
13 replies
FFilament
Created by PabloZagni on 8/4/2024 in #❓┊help
How to refresh a relationManager after Action on Owner.
Yeah I saw some people are redirecting after the action completed... it feels strange 🙂
13 replies
FFilament
Created by kennyhorna on 8/11/2024 in #❓┊help
How to re-render/refresh the parent form after a new entry of a RelationManager has been created?
No description
18 replies
FFilament
Created by PabloZagni on 8/4/2024 in #❓┊help
How to refresh a relationManager after Action on Owner.
No description
13 replies
FFilament
Created by kennyhorna on 8/11/2024 in #❓┊help
How to re-render/refresh the parent form after a new entry of a RelationManager has been created?
so in affect they are two seperate components
18 replies
FFilament
Created by kennyhorna on 8/11/2024 in #❓┊help
How to re-render/refresh the parent form after a new entry of a RelationManager has been created?
So the product list page is a resource with a table which also have the button to add something to the cart. The Cart Page is a separate component, when viewing the products the cart only have a navigation item with a badge with the number of items in the cart.
18 replies
FFilament
Created by PabloZagni on 8/4/2024 in #❓┊help
How to refresh a relationManager after Action on Owner.
Hey @Dennis Koch trying to figure out what the correct way to dispatch a Livewire Event and Listener. Can't seem to find specifics in the docs. Do you maybe have some pointers, I've tried and search a lot: I have a ProductResource and next to each product in a filament table I have a add to cart button/action:
->actions([
Action::make('basket')
->requiresConfirmation()
->after(function () {
$this->dispatch('updated_cart'); <-- throws error: Using $this when not in object context
})
->action(function (Event $record) {
app()->make('cart')->addEvent($record->id);
}),
])
->actions([
Action::make('basket')
->requiresConfirmation()
->after(function () {
$this->dispatch('updated_cart'); <-- throws error: Using $this when not in object context
})
->action(function (Event $record) {
app()->make('cart')->addEvent($record->id);
}),
])
First when I try to dispatch the event like in the above code I get an error: Using $this when not in object context Also tried the one below does not throw an error but I am also not sure if the event is even dispatched at all:
->after(function (StaticAction $action) {
$action->dispatch('updated_cart');
})
->after(function (StaticAction $action) {
$action->dispatch('updated_cart');
})
There's a simple filament page with a side navigation and a badge counter. I've tried various ways to listen for the event without getting it to refresh. When a user add an item to the cart the counter should update via listening for the 'updated_cart' event:
class Cart extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-shopping-cart';

protected static string $view = 'filament.pages.test';

protected $listeners = ['updated_cart' => '$refresh']; <-- tried this

#[On('updated_cart')] <-- tried this
public static function refreshBadgeCount()
{
$count = app()->make('cart')->eventCount();

return $count > 0 ? $count : null;
}

#[On('updated_cart')] <-- tried this
public static function getNavigationBadge(): ?string
{
return static::refreshBadgeCount();
}
class Cart extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-shopping-cart';

protected static string $view = 'filament.pages.test';

protected $listeners = ['updated_cart' => '$refresh']; <-- tried this

#[On('updated_cart')] <-- tried this
public static function refreshBadgeCount()
{
$count = app()->make('cart')->eventCount();

return $count > 0 ? $count : null;
}

#[On('updated_cart')] <-- tried this
public static function getNavigationBadge(): ?string
{
return static::refreshBadgeCount();
}
I suspect dispatching is the problem.
13 replies
FFilament
Created by kennyhorna on 8/11/2024 in #❓┊help
How to re-render/refresh the parent form after a new entry of a RelationManager has been created?
Ok tried the dd()
class Cart extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-shopping-cart';

protected static string $view = 'filament.pages.test';

protected $listeners = ['updated_cart' => '$refresh'];

#[On('updated_cart')]
public static function test()
{
dd('x');
}

public static function refreshBadgeCount()
{
$count = app()->make('cart')->eventCount();

return $count > 0 ? $count : null;
}

public static function getNavigationBadge(): ?string
{
return static::refreshBadgeCount();
}
class Cart extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-shopping-cart';

protected static string $view = 'filament.pages.test';

protected $listeners = ['updated_cart' => '$refresh'];

#[On('updated_cart')]
public static function test()
{
dd('x');
}

public static function refreshBadgeCount()
{
$count = app()->make('cart')->eventCount();

return $count > 0 ? $count : null;
}

public static function getNavigationBadge(): ?string
{
return static::refreshBadgeCount();
}
Not reached. Hence I think it is on the dispatching side where the problem lies.
18 replies
FFilament
Created by kennyhorna on 8/11/2024 in #❓┊help
How to re-render/refresh the parent form after a new entry of a RelationManager has been created?
Yeah in the actual code there is only 1, it was just to illustrate where I have tried it. Quickly trying the dd()
18 replies
FFilament
Created by kennyhorna on 8/11/2024 in #❓┊help
How to re-render/refresh the parent form after a new entry of a RelationManager has been created?
I've fixed that typo, still not working, I think the issue is how to dispatch the event. As mentioned in my code above when I do: $this->dispatch() it gives me the error.
18 replies
FFilament
Created by kennyhorna on 8/11/2024 in #❓┊help
How to re-render/refresh the parent form after a new entry of a RelationManager has been created?
I'm quickly double-checking
18 replies
FFilament
Created by kennyhorna on 8/11/2024 in #❓┊help
How to re-render/refresh the parent form after a new entry of a RelationManager has been created?
Hey @kennyhorna seems like you've played with dispatching and listening to events. I'm going crazy on this one. Here my scenario using filament 3 : I have a ProductResource and next to each product in a table I have a add to cart button/action:
->actions([
Action::make('basket')
->requiresConfirmation()
->after(function () {
$this->dispatch('updated_cart'); <-- throws error: Using $this when not in object context
})
->icon('heroicon-o-shopping-cart')
->iconButton()
->action(function (Event $record) {
app()->make('cart')->addEvent($record->id);
}),
])
->actions([
Action::make('basket')
->requiresConfirmation()
->after(function () {
$this->dispatch('updated_cart'); <-- throws error: Using $this when not in object context
})
->icon('heroicon-o-shopping-cart')
->iconButton()
->action(function (Event $record) {
app()->make('cart')->addEvent($record->id);
}),
])
First when I try to dispatch the event like in the above code I get an error: Using $this when not in object context I've tried various variants for example, the one below does not throw an error but I am also not sure if the event is even dispatched at all:
->after(function (StaticAction $action) {
$action->dispatch('updated_cart');
})
->after(function (StaticAction $action) {
$action->dispatch('updated_cart');
})
There's a simple filament page with a side navigation and a badge counter. I've tried various ways to listen for the event without getting it to refresh. When a user add an item to the cart it should update via listening for the 'updated_cart' event:
class Cart extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-shopping-cart';

protected static string $view = 'filament.pages.test';

protected $listeners = ['updated_cart' => '$refresh'];

#[On('updated_cart')]
public static function refreshBadgeCount()
{
$count = app()->make('cart')->eventCount();

return $count > 0 ? $count : null;
}

#[On('updated_cart')]
public static function getNavigationBadge(): ?string
{
return static::refreshBadgeCount();
}
class Cart extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-shopping-cart';

protected static string $view = 'filament.pages.test';

protected $listeners = ['updated_cart' => '$refresh'];

#[On('updated_cart')]
public static function refreshBadgeCount()
{
$count = app()->make('cart')->eventCount();

return $count > 0 ? $count : null;
}

#[On('updated_cart')]
public static function getNavigationBadge(): ?string
{
return static::refreshBadgeCount();
}
Do you have maybe any tips or tricks for this?
18 replies
FFilament
Created by Alvika Aji Prahasta on 8/14/2024 in #❓┊help
Table TextInputColumn Update Other Model
@Alvika Aji Prahasta me again 🙂 is the listener on your example working and how are you dispatching the event?
7 replies
FFilament
Created by Alvika Aji Prahasta on 8/21/2024 in #❓┊help
Unable to find component: [app.filament.widgets.kickoff-property-table-widget]
Hey @Alvika Aji Prahasta did you maybe find a solution to this. I have a similar situation where i am trying to refresh a component, thus it needs to listen to a Livewire event I want to throw?
3 replies