Hello guys newbie over here, I have 2 tables right now(MasterListing & DetailListing), a column in DetailListing table called "reference" which I use to separate all the data(ex: reference '1' is for accounting data, '2' is for HR data).
In my scenario I have a master listing page(https://i.stack.imgur.com/p4s5A.jpg), when I click on #1 BROWSE, it should redirect me to detail listing page and show DetailListing data with only reference '1', when I click on #2 BROWSE it should only show reference '2', etc.
This Detail Listing controller function will redirect user from MasterListing page to DetailListing page once they click the BROWSE button, however, I don't know what to put after 'reference' to make it display the correct specific data so I just temporally put 1 as placeholder(it displayed data with reference'1').
public function show(DetailListing $data)
{
$data = DetailListing::where('reference', 1 )->get();
return view('detaillisting',['data'=>$data]);
}
FYI, this is the function in Master Listing Controller that show all MasterListing data :
public index()
{
$data = DB::select('select * from masterlisting');
return view('masterlisting',['data'=>$data]);
}
masterlisting.blade.php
<tbody>
@foreach ($data as $row)
<tr>
<td> {{ $row->id }} </td>
<td> {{ $row->Name }} </td>
<td> {{ $row->Description }} </td>
<td> {{ $row->Type }} </td>
<td><button class="btn btn-success" onclick="location.href = 'detaillisting/{{ $row->id }}';">BROWSE</button></td>
</tr>
@endforeach
</tbody>