Add shared data to Infolist Livewire fields
I am using custom LiveWire components in my Infolist which look like so:
But both of those components are making an identical call in the mount() function like so:
and
So i wanted to create the variable $data in the infolist function but i am unable to access the resource here.
Wanted situation:
And then i would call the Livewire components as followed:
All this would be to not call the same Animal function on one page (since this is an API call to a third party). How would i be able to create an $data variable like above to pass to multiple Livewire fields in my infolist?
16 Replies
As long as your livewire components have a ‘data’ property I don’t see why this wouldn’t work.
Well somehow I need the current $resource in the infolist function. But I’m not sure how to get the current resource in there.
$resource or $record?
Record
:p
static::$record or static::getRecord()
Something like that.
Lemme try
Could be static::getResource()->getRecord() too. Don’t remember of the top of my head.
All methods not found 😦
Is this in a panel or stand alone infolist package?
Its a panel
static::getModel() if your are on the Resource class.
Thats giving me "App\Models\Animal"
So the model used
I got it 😮
Solution
This works
Thanks to you @awcodes , you just gave me the insights to look a bit deeper <#
Glad you found it. Trying to source dive on my phone. Sorry. 😂
No problem, youve been a great help
Thanks alot