-2

I'm getting the following error:

Undefined variable: ticketinfo (View: C:\xampp\htdocs\violation\resources\views\records\show.blade.php)

I don't know how to fix it. :(

This my html code:

<table class="table table-striped table-hover table-bordered">
  <thead>
    <tr>
      <th>Ticket No.</th>
      <th>Type of Violation</th>
      <th>Violation Code</th>
      <th>Violation Name</th>
      <th>Apprehending Officer</th>
      <th>Remarks</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{ $ticketinfo->ticketno }}</td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
    </tr>
  </tbody>
</table>

This is my Controller code

public function show($id)
{
    $ticketinfo = ticket::find($id);
    return view('records.show', compact('ticketinfo'));
}
Axel
  • 3,331
  • 11
  • 35
  • 58

1 Answers1

0

You did compact('tickets'), but your variable is called $ticketinfo.

Do compact('ticketinfo') instead. The naming matters.

ceejayoz
  • 176,543
  • 40
  • 303
  • 368