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

Time:02-07

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 >
  <div >
    <h3 ><a href="{{ route('marketthreads.show', $thread->id) }}">{{ $thread->subject }}</a></h3>
  </div>
  <div >
      <p >{{ \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 :)

CodePudding user response:

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

  •  Tags:  
  • Related