Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing data to layout of a Volt full page component #122

Closed
wants to merge 1 commit into from

Conversation

undjike
Copy link

@undjike undjike commented Nov 6, 2024

This pull request enable sharing data passed using with helper with the layout component as well.

This is to solve the issue #121.

@undjike
Copy link
Author

undjike commented Nov 6, 2024

@nunomaduro what do you think?

@taylorotwell
Copy link
Collaborator

You should use View::share to get data to the layout.

@undjike
Copy link
Author

undjike commented Nov 7, 2024

Hello @taylorotwell thanks for the trick. I replaced with() by view()->share() in the PHP section of the Volt component and everything is working as expected.

@undjike
Copy link
Author

undjike commented Nov 10, 2024

Hello @taylorotwell sorry for coming up again. I still have issues when it comes to pass a component variable to the layout using View::share.

view()->share('breadcrumbs', [
    ['label' => __('Management')],
    ['label' => __('Plannings'), 'link' => route('plannings')],
    ['label' => $this->plan->name, 'current' => true]
]);

@undjike
Copy link
Author

undjike commented Nov 10, 2024

Where plan comes from a route parameter binding to a model.

I get the error message Using $this when not in object context.
Without $this I get Undefined property: Livewire\Volt\Methods\ComputedMethod::$name or Undefined variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants