Struggling to pass data along with view

What seems to be the problem: I have a complex query with multiple children which I need to pass to the view. I seem to be struggling to find a working way to pass the model to the view

Steps to Reproduce:
In render method, perform query, creating variable representing model, pass model to the view using one of the following methods;

    return view('myview')->withContact($contact);

    return view('myview')->with(['contact' => $contact]);

    return view('myview', compact('contact'));

    return view('myview', ['contact' => $contact]);

Are you using the latest version of Livewire: 1.0.14

Do you have any screenshots or code examples:

I need someone to tell me this should work, so I know I’m doing something stupid… or this is not possible. ( Its not exampled in the docs. )

I just did a sanity check on the same version and it works. Tested with

$test = SomeModel::first();
return view(...)->withTest($test);

I’d say first debugging step is see if debugbar is showing the parameter being passed to the view. If you haven’t used that part before, when you click on the view, it will give you a parameter list.

image

Thanks for your help. I verified with debugbar and yes, that field was being sent to the view.

However, I have found the problem ! Left over from a previous iteration was a public field of the same name. Palm meets face moment…

1 Like

97% of all issues :grinning: