JunDev
JunDev

Reputation: 15

LARAVEL: Data not showing on a page but works fine for other page

Im having a bit of a weird problem as a similar piece of code works for another page but it won't work for this, I can add to the database using my website but when trying to show the data it comes up as blank. Im not exactly sure what I am doing wrong and its starting to frustrate me, here's some code

Index.blade.php

<div class="panel panel-primary">
  <div class="panel-heading">
    <h3 class="panel-title"><a href="{{ route('marketthreads.show', $thread->id) }}">{{ $thread->subject }}</a></h3>
  </div>
  <div class="panel-body">
      <p class="list-group-item-text">{{ \Illuminate\Support\Str::limit($thread->thread,100) }}
          <br>
          <br>
          {{ $thread->id }}
      </p>
  </div>

The Controller

    public function show(Marketthreads $marketthreads)
{
    return view('marketplace.details', compact('marketthreads'));
}

Web file (routes)

Route::resource('/marketthreads', App\Http\Controllers\MarketthreadsController::class);

Details.blade.php (the file im trying to show the data on)

Details.blade

As I mentioned before this works for another page that I have done and it shows the data but it pulls data from another table I don't think that matters too much

Hopefully someone can help me out, thank you :)

Upvotes: 1

Views: 488

Answers (1)

ruleboy21
ruleboy21

Reputation: 6391

You are using $thread which is undefined. In your controller you are passing $marketthreads to the view via compact('marketthreads'). So you should change $thread to $marketthreads

Upvotes: 1

Related Questions