Closed kahfieidn closed 11 months ago
I solved this with while solution:
go to dir : vendor/protonemedia/laravel-splade/src/Components/PersistentComponent.php
public function viewData(array $originalData, HtmlString $slot, Factory $env): array
{
$slots = Collection::make($env->getFirstSlot())->map(function (ComponentSlot $slot, $name) {
return new ComponentSlot(
$this->wrapSlotContents($name, $slot)->toHtml(),
$slot->attributes->getAttributes()
);
});
return array_merge(
$originalData,
$slots->all(),
['slot' => $this->wrapSlotContents('slot', $slot)]
);
}
Remove HtmlString in behind $slot, then finaly function viewData like this:
public function viewData(array $originalData, $slot, Factory $env): array
{
$slots = Collection::make($env->getFirstSlot())->map(function (ComponentSlot $slot, $name) {
return new ComponentSlot(
$this->wrapSlotContents($name, $slot)->toHtml(),
$slot->attributes->getAttributes()
);
});
return array_merge(
$originalData,
$slots->all(),
['slot' => $this->wrapSlotContents('slot', $slot)]
);
}
Working fine for me, this is not best solution, maybe anyone have better solution
Replace HtmlString
with ComponentSlot
instead of removing it. After that the viewData should look like below
public function viewData(array $originalData, ComponentSlot $slot, Factory $env): array
{
$slots = Collection::make($env->getFirstSlot())->map(function (ComponentSlot $slot, $name) {
return new ComponentSlot(
$this->wrapSlotContents($name, $slot)->toHtml(),
$slot->attributes->getAttributes()
);
});
return array_merge(
$originalData,
$slots->all(),
['slot' => $this->wrapSlotContents('slot', $slot)]
);
}
Thanks a lot! Working fine
Follow the instructions given in the documentation. https://splade.dev/docs/persistent-layout
I try to implement persistent layout but not working
here is the error :
Any solve for this?