Cannot get model from livewire

What seems to be the problem: I can’t get a model from livewire and return it to the view.

Steps to Reproduce: I want to get data from the database and display it to livewire views.

Are you using the latest version of Livewire: Yes

Do you have any screenshots or code examples: I am trying this `
public $pressList;

public function mount()
{
    $user_id = Auth::user()->id;

    $this->$pressList = Press::where('user_id', $user_id);

}

and this is my blade

 <div>
    @foreach ($pressList as $press)
        {{ $press->title }}
    @endforeach
  </div>

$this->pressList = Press::where('user_id', $user_id)->get();

1 Like

@hortigado thank you so much. That was my problem.
Is there a way I can get a single press with a Livewire component.

with Laravel it is

public function show($id)
{
     // Id available via the get from the route 
    // Route::get('ulr/{id}, 'Controller@show);
}

I need a similar functionality with Livewire. I am unable to get the id.
Thanks.

wire:click="show({{$reseña->id}})"

public function show($id)

    {

}
1 Like

@hortigado try this

<a href="press/{{ $press->id }}" wire:click="show({{ $press->id }})">{{ $press->title }}</a> or
<button wire:click="show({{ $press->id }})"> {{ $press->title }}</button>

does not fire the show method

public function show($id)
    {
        dd($id);

    }

if there is no console error then if it is firing

1 Like

@hortigado there is no error but I find no way to show a single Press (Model) to the view from that method.

$this->pressList = Press::where('user_id', $user_id)->first();