custom field viewData closure returns empty always
hi , im trying to make a custom item list cards for packages
the following implementation works fine
however when i do the following it doesn't return anything ,
what am i missing or doing wrong ?
any help is appreciated
the following implementation works fine
class PackageCard extends Field
{
protected string $view = 'forms.components.package-card';
}
//in resource
PackageCard::make("package_id")
->viewData([
'packages' => Package::query()->get()
])
//package-card.blade.php:
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
wire:ignore
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
<!-- Interact with the `state` property in Alpine.js -->
@foreach($packages as $package)
<p>{{$package->name}}</p>
@endforeach
</div>
</x-dynamic-component>class PackageCard extends Field
{
protected string $view = 'forms.components.package-card';
}
//in resource
PackageCard::make("package_id")
->viewData([
'packages' => Package::query()->get()
])
//package-card.blade.php:
<x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
wire:ignore
>
<div x-data="{ state: $wire.$entangle('{{ $getStatePath() }}') }">
<!-- Interact with the `state` property in Alpine.js -->
@foreach($packages as $package)
<p>{{$package->name}}</p>
@endforeach
</div>
</x-dynamic-component>however when i do the following it doesn't return anything ,
'packages' => fn(Forms\Get $get): Collection => Package::query()->where('country_id', $get("country_id"))->get()
//country select in the resource :
Select::make('country_id')
->options(Country::all()->pluck('name', 'id'))
->label(__("Country"))
->suffixIcon('heroicon-m-map-pin')
->hint(__("Please select the desired country of incorporation."))
->required()
->live()
->preload()
->searchable()'packages' => fn(Forms\Get $get): Collection => Package::query()->where('country_id', $get("country_id"))->get()
//country select in the resource :
Select::make('country_id')
->options(Country::all()->pluck('name', 'id'))
->label(__("Country"))
->suffixIcon('heroicon-m-map-pin')
->hint(__("Please select the desired country of incorporation."))
->required()
->live()
->preload()
->searchable()what am i missing or doing wrong ?
any help is appreciated