I have two methods in my callsController. The first is called newCall and it displays all the records from a DB table, it looks like this :
public function newCall(){
$new_calls = new_calls::all(); //fetches everything in the new_calls table in the database
return view('calls.newCall')->with('new_calls', $new_calls); //passes it to the view
}
This function is working well and all the records are successfully retrieved in my view.
The issue is with the second method viewCall whose aim is to show data for a single call when its name is clicked from the list of newCalls.
Currently, I have just this:
public function viewCall(){
return view('calls.viewCall');
}
I plan on formatting the data from the database (for a particular call) with some static text while displaying it in my viewCall.blade.php.
I wasn't really sure what to put in web.php, so my routes look like this :
Route::get('/calls/newCall', 'CallsController@newCall');
Route::get('/calls/viewCall/{id}', 'CallsController@viewCall')->name('viewCall');
Can someone help me make this work? I just want to see the associative array with the record from the database when I click on a call's name. What do I need to add in routes and in my view?
This is my newCall.blade.php
<div class="table-responsive">
<table class="table no-margin table-striped">
<thead>
<tr>
<th>Terminal ID</th>
<th>Terminal Name</th>
{{-- <th>Fault Description</th> --}}
<th>Call Logged On</th>
<th>ATM Variant</th>
</tr>
</thead>
<tbody>
@if(count($new_calls) > 0)
@foreach($new_calls as $calls)
<tr>
<td><a href="/calls/viewCall/{{$calls->id}}" title="view more details">{{$calls->terminal_id}}</a></td>
<td>{{$calls->terminal_name}}</td>
{{-- <td style="width:350px">{{$calls->fault_description}}</td> --}}
<td>{{$calls->created_at}}</td>
<td>{{$calls->atm_variant}}</td>
</tr>
@endforeach
@else
<h1>No new Calls</h1>
@endif
</tbody>
</table>
</div>
This is my viewCall.blade.php
<address>
<strong>{{$new_call->client_name}}</strong><br>
{{$new_call->address}}<br>
<b>Phone: {{$new_call->phone}}</b> <br>
<b>Email: {{$new_call->email}}</b>
</address>
nb: I have also tried using {{$calls->email}} but it's returning undefined variable: calls and new_calls in each case
newcall.blade.phpandviewcall.blade.phpfile and I will look at it.undefined variable callserror