Displaying a single record from Database in laravel
up vote
2
down vote
favorite
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
php laravel
add a comment |
up vote
2
down vote
favorite
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
php laravel
Check my answer below and tell me if it works for you or not.
– rpm192
Nov 10 at 10:56
Add yournewcall.blade.php
andviewcall.blade.php
file and I will look at it.
– rpm192
Nov 11 at 11:54
Did you updated your viewCall function as shown in my answer below?
– rpm192
Nov 11 at 16:48
yes...please view the updated version of my post..I included my foreach statement.. am still getting theundefined variable calls
error
– Austin
Nov 12 at 8:52
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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
php laravel
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
php laravel
php laravel
edited Nov 11 at 16:14
asked Nov 9 at 15:00
Austin
2110
2110
Check my answer below and tell me if it works for you or not.
– rpm192
Nov 10 at 10:56
Add yournewcall.blade.php
andviewcall.blade.php
file and I will look at it.
– rpm192
Nov 11 at 11:54
Did you updated your viewCall function as shown in my answer below?
– rpm192
Nov 11 at 16:48
yes...please view the updated version of my post..I included my foreach statement.. am still getting theundefined variable calls
error
– Austin
Nov 12 at 8:52
add a comment |
Check my answer below and tell me if it works for you or not.
– rpm192
Nov 10 at 10:56
Add yournewcall.blade.php
andviewcall.blade.php
file and I will look at it.
– rpm192
Nov 11 at 11:54
Did you updated your viewCall function as shown in my answer below?
– rpm192
Nov 11 at 16:48
yes...please view the updated version of my post..I included my foreach statement.. am still getting theundefined variable calls
error
– Austin
Nov 12 at 8:52
Check my answer below and tell me if it works for you or not.
– rpm192
Nov 10 at 10:56
Check my answer below and tell me if it works for you or not.
– rpm192
Nov 10 at 10:56
Add your
newcall.blade.php
and viewcall.blade.php
file and I will look at it.– rpm192
Nov 11 at 11:54
Add your
newcall.blade.php
and viewcall.blade.php
file and I will look at it.– rpm192
Nov 11 at 11:54
Did you updated your viewCall function as shown in my answer below?
– rpm192
Nov 11 at 16:48
Did you updated your viewCall function as shown in my answer below?
– rpm192
Nov 11 at 16:48
yes...please view the updated version of my post..I included my foreach statement.. am still getting the
undefined variable calls
error– Austin
Nov 12 at 8:52
yes...please view the updated version of my post..I included my foreach statement.. am still getting the
undefined variable calls
error– Austin
Nov 12 at 8:52
add a comment |
3 Answers
3
active
oldest
votes
up vote
0
down vote
accepted
What you need to do is get the new_calls
model by the ID
. Which you can do like so:
routes/web.php
Route::get('/calls/viewCall/id', 'CallsController@viewCall');
CallsController.php
public function viewCall($id) // the id in the url
$new_call = new_calls::find($id);
return view('calls.viewCall')->with('new_call', $new_call);
In your view (I assume you're looping through all the calls to display them) create a link.
// your existing foreach
@foreach($x as $y)
<a href="/calls/viewCall/$y->id">View Call</a>
@endforeach
That's whatreturn view('calls.viewCall')->with('new_call', $new_call);
does. In your view, you can access the call like so:$new_call
with any properties.
– rpm192
Nov 10 at 16:53
Just add the view that you want the link to the call page in and I'll look at it.
– rpm192
Nov 10 at 16:55
I tried<small class="pull-right">Call logged on: $new_call->created_at </small>
and I got the undefined variablenew_call
error
– Austin
Nov 10 at 16:58
You should use$new_call->created_at
. Because the properties get passed into the view as$new_call
– rpm192
Nov 10 at 16:58
I also tried that and got the same error
– Austin
Nov 10 at 17:01
|
show 4 more comments
up vote
1
down vote
You can do something like this:
public function viewCall($id)
return view('calls.viewCall', ['call' => new_calls::findOrFail($id)]);
This will get the id
from the route and call a function to find the object with the given id
.
If you have problems to deal with the variable in the view. Try to check the object using dd
. Try this:
public function viewCall($id)
$new_call = new_calls::find($id);
dd($new_call);
Ref: https://laravel.com/docs/5.7/controllers#basic-controllers
thanks for your response...but I did that but nothing happened..
– Austin
Nov 9 at 15:22
Do you have any code inviewCall
?
– Laerte
Nov 9 at 15:25
nothing is there except HTML and CSS codes but they are all imported as the headers and the footer
– Austin
Nov 9 at 15:48
I was hoping to view the data in its raw state ie in array so i can customize the view
– Austin
Nov 9 at 15:56
1
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
|
show 2 more comments
up vote
0
down vote
I recommend too looking at naming convetions and route model binding and type hinting in the controller.
Then you'd have something like this:
public function viewCall(NewCall $newcall)
return view('calls.viewCall')->with($newcall);
and route would be like this:
Route::get('/calls/viewCall/newcall', 'CallsController@viewCall')->name('viewCall');
thanks for your response but it says "Class AppHttpControllersNewCall does not exist"
– Austin
Nov 9 at 15:45
So where you did: $new_call = new_calls::find($id); new_calls is your class. That is poor naming convention. Your model is new_calls and should be singular. Think of a model as 1 row in the DB. new_call::allI() = all rows. new_fall::find($id) == 1 row. I would change my model to NewCall but since you did it like that already you can do: Public function viewCall(new_calls, $newcall) return view('calls.viewCall')->with($newcall); . Now what you are type hinting at is $newcall is an instance of new_call. It is an eloquent.
– Brad Goldsmith
Nov 10 at 19:35
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
@Austin . Really read those laravel docs. Route model binding and type hinting are so important and help keep code clean/readable, which will go a long way. Good luck with your project.
– Brad Goldsmith
Nov 12 at 14:48
thanks for the info...am already on it
– Austin
Nov 12 at 16:41
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
What you need to do is get the new_calls
model by the ID
. Which you can do like so:
routes/web.php
Route::get('/calls/viewCall/id', 'CallsController@viewCall');
CallsController.php
public function viewCall($id) // the id in the url
$new_call = new_calls::find($id);
return view('calls.viewCall')->with('new_call', $new_call);
In your view (I assume you're looping through all the calls to display them) create a link.
// your existing foreach
@foreach($x as $y)
<a href="/calls/viewCall/$y->id">View Call</a>
@endforeach
That's whatreturn view('calls.viewCall')->with('new_call', $new_call);
does. In your view, you can access the call like so:$new_call
with any properties.
– rpm192
Nov 10 at 16:53
Just add the view that you want the link to the call page in and I'll look at it.
– rpm192
Nov 10 at 16:55
I tried<small class="pull-right">Call logged on: $new_call->created_at </small>
and I got the undefined variablenew_call
error
– Austin
Nov 10 at 16:58
You should use$new_call->created_at
. Because the properties get passed into the view as$new_call
– rpm192
Nov 10 at 16:58
I also tried that and got the same error
– Austin
Nov 10 at 17:01
|
show 4 more comments
up vote
0
down vote
accepted
What you need to do is get the new_calls
model by the ID
. Which you can do like so:
routes/web.php
Route::get('/calls/viewCall/id', 'CallsController@viewCall');
CallsController.php
public function viewCall($id) // the id in the url
$new_call = new_calls::find($id);
return view('calls.viewCall')->with('new_call', $new_call);
In your view (I assume you're looping through all the calls to display them) create a link.
// your existing foreach
@foreach($x as $y)
<a href="/calls/viewCall/$y->id">View Call</a>
@endforeach
That's whatreturn view('calls.viewCall')->with('new_call', $new_call);
does. In your view, you can access the call like so:$new_call
with any properties.
– rpm192
Nov 10 at 16:53
Just add the view that you want the link to the call page in and I'll look at it.
– rpm192
Nov 10 at 16:55
I tried<small class="pull-right">Call logged on: $new_call->created_at </small>
and I got the undefined variablenew_call
error
– Austin
Nov 10 at 16:58
You should use$new_call->created_at
. Because the properties get passed into the view as$new_call
– rpm192
Nov 10 at 16:58
I also tried that and got the same error
– Austin
Nov 10 at 17:01
|
show 4 more comments
up vote
0
down vote
accepted
up vote
0
down vote
accepted
What you need to do is get the new_calls
model by the ID
. Which you can do like so:
routes/web.php
Route::get('/calls/viewCall/id', 'CallsController@viewCall');
CallsController.php
public function viewCall($id) // the id in the url
$new_call = new_calls::find($id);
return view('calls.viewCall')->with('new_call', $new_call);
In your view (I assume you're looping through all the calls to display them) create a link.
// your existing foreach
@foreach($x as $y)
<a href="/calls/viewCall/$y->id">View Call</a>
@endforeach
What you need to do is get the new_calls
model by the ID
. Which you can do like so:
routes/web.php
Route::get('/calls/viewCall/id', 'CallsController@viewCall');
CallsController.php
public function viewCall($id) // the id in the url
$new_call = new_calls::find($id);
return view('calls.viewCall')->with('new_call', $new_call);
In your view (I assume you're looping through all the calls to display them) create a link.
// your existing foreach
@foreach($x as $y)
<a href="/calls/viewCall/$y->id">View Call</a>
@endforeach
edited Nov 9 at 23:18
answered Nov 9 at 22:55
rpm192
1,0751417
1,0751417
That's whatreturn view('calls.viewCall')->with('new_call', $new_call);
does. In your view, you can access the call like so:$new_call
with any properties.
– rpm192
Nov 10 at 16:53
Just add the view that you want the link to the call page in and I'll look at it.
– rpm192
Nov 10 at 16:55
I tried<small class="pull-right">Call logged on: $new_call->created_at </small>
and I got the undefined variablenew_call
error
– Austin
Nov 10 at 16:58
You should use$new_call->created_at
. Because the properties get passed into the view as$new_call
– rpm192
Nov 10 at 16:58
I also tried that and got the same error
– Austin
Nov 10 at 17:01
|
show 4 more comments
That's whatreturn view('calls.viewCall')->with('new_call', $new_call);
does. In your view, you can access the call like so:$new_call
with any properties.
– rpm192
Nov 10 at 16:53
Just add the view that you want the link to the call page in and I'll look at it.
– rpm192
Nov 10 at 16:55
I tried<small class="pull-right">Call logged on: $new_call->created_at </small>
and I got the undefined variablenew_call
error
– Austin
Nov 10 at 16:58
You should use$new_call->created_at
. Because the properties get passed into the view as$new_call
– rpm192
Nov 10 at 16:58
I also tried that and got the same error
– Austin
Nov 10 at 17:01
That's what
return view('calls.viewCall')->with('new_call', $new_call);
does. In your view, you can access the call like so: $new_call
with any properties.– rpm192
Nov 10 at 16:53
That's what
return view('calls.viewCall')->with('new_call', $new_call);
does. In your view, you can access the call like so: $new_call
with any properties.– rpm192
Nov 10 at 16:53
Just add the view that you want the link to the call page in and I'll look at it.
– rpm192
Nov 10 at 16:55
Just add the view that you want the link to the call page in and I'll look at it.
– rpm192
Nov 10 at 16:55
I tried
<small class="pull-right">Call logged on: $new_call->created_at </small>
and I got the undefined variable new_call
error– Austin
Nov 10 at 16:58
I tried
<small class="pull-right">Call logged on: $new_call->created_at </small>
and I got the undefined variable new_call
error– Austin
Nov 10 at 16:58
You should use
$new_call->created_at
. Because the properties get passed into the view as $new_call
– rpm192
Nov 10 at 16:58
You should use
$new_call->created_at
. Because the properties get passed into the view as $new_call
– rpm192
Nov 10 at 16:58
I also tried that and got the same error
– Austin
Nov 10 at 17:01
I also tried that and got the same error
– Austin
Nov 10 at 17:01
|
show 4 more comments
up vote
1
down vote
You can do something like this:
public function viewCall($id)
return view('calls.viewCall', ['call' => new_calls::findOrFail($id)]);
This will get the id
from the route and call a function to find the object with the given id
.
If you have problems to deal with the variable in the view. Try to check the object using dd
. Try this:
public function viewCall($id)
$new_call = new_calls::find($id);
dd($new_call);
Ref: https://laravel.com/docs/5.7/controllers#basic-controllers
thanks for your response...but I did that but nothing happened..
– Austin
Nov 9 at 15:22
Do you have any code inviewCall
?
– Laerte
Nov 9 at 15:25
nothing is there except HTML and CSS codes but they are all imported as the headers and the footer
– Austin
Nov 9 at 15:48
I was hoping to view the data in its raw state ie in array so i can customize the view
– Austin
Nov 9 at 15:56
1
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
|
show 2 more comments
up vote
1
down vote
You can do something like this:
public function viewCall($id)
return view('calls.viewCall', ['call' => new_calls::findOrFail($id)]);
This will get the id
from the route and call a function to find the object with the given id
.
If you have problems to deal with the variable in the view. Try to check the object using dd
. Try this:
public function viewCall($id)
$new_call = new_calls::find($id);
dd($new_call);
Ref: https://laravel.com/docs/5.7/controllers#basic-controllers
thanks for your response...but I did that but nothing happened..
– Austin
Nov 9 at 15:22
Do you have any code inviewCall
?
– Laerte
Nov 9 at 15:25
nothing is there except HTML and CSS codes but they are all imported as the headers and the footer
– Austin
Nov 9 at 15:48
I was hoping to view the data in its raw state ie in array so i can customize the view
– Austin
Nov 9 at 15:56
1
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
|
show 2 more comments
up vote
1
down vote
up vote
1
down vote
You can do something like this:
public function viewCall($id)
return view('calls.viewCall', ['call' => new_calls::findOrFail($id)]);
This will get the id
from the route and call a function to find the object with the given id
.
If you have problems to deal with the variable in the view. Try to check the object using dd
. Try this:
public function viewCall($id)
$new_call = new_calls::find($id);
dd($new_call);
Ref: https://laravel.com/docs/5.7/controllers#basic-controllers
You can do something like this:
public function viewCall($id)
return view('calls.viewCall', ['call' => new_calls::findOrFail($id)]);
This will get the id
from the route and call a function to find the object with the given id
.
If you have problems to deal with the variable in the view. Try to check the object using dd
. Try this:
public function viewCall($id)
$new_call = new_calls::find($id);
dd($new_call);
Ref: https://laravel.com/docs/5.7/controllers#basic-controllers
edited Nov 9 at 16:33
answered Nov 9 at 15:04
Laerte
5,12132040
5,12132040
thanks for your response...but I did that but nothing happened..
– Austin
Nov 9 at 15:22
Do you have any code inviewCall
?
– Laerte
Nov 9 at 15:25
nothing is there except HTML and CSS codes but they are all imported as the headers and the footer
– Austin
Nov 9 at 15:48
I was hoping to view the data in its raw state ie in array so i can customize the view
– Austin
Nov 9 at 15:56
1
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
|
show 2 more comments
thanks for your response...but I did that but nothing happened..
– Austin
Nov 9 at 15:22
Do you have any code inviewCall
?
– Laerte
Nov 9 at 15:25
nothing is there except HTML and CSS codes but they are all imported as the headers and the footer
– Austin
Nov 9 at 15:48
I was hoping to view the data in its raw state ie in array so i can customize the view
– Austin
Nov 9 at 15:56
1
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
thanks for your response...but I did that but nothing happened..
– Austin
Nov 9 at 15:22
thanks for your response...but I did that but nothing happened..
– Austin
Nov 9 at 15:22
Do you have any code in
viewCall
?– Laerte
Nov 9 at 15:25
Do you have any code in
viewCall
?– Laerte
Nov 9 at 15:25
nothing is there except HTML and CSS codes but they are all imported as the headers and the footer
– Austin
Nov 9 at 15:48
nothing is there except HTML and CSS codes but they are all imported as the headers and the footer
– Austin
Nov 9 at 15:48
I was hoping to view the data in its raw state ie in array so i can customize the view
– Austin
Nov 9 at 15:56
I was hoping to view the data in its raw state ie in array so i can customize the view
– Austin
Nov 9 at 15:56
1
1
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
|
show 2 more comments
up vote
0
down vote
I recommend too looking at naming convetions and route model binding and type hinting in the controller.
Then you'd have something like this:
public function viewCall(NewCall $newcall)
return view('calls.viewCall')->with($newcall);
and route would be like this:
Route::get('/calls/viewCall/newcall', 'CallsController@viewCall')->name('viewCall');
thanks for your response but it says "Class AppHttpControllersNewCall does not exist"
– Austin
Nov 9 at 15:45
So where you did: $new_call = new_calls::find($id); new_calls is your class. That is poor naming convention. Your model is new_calls and should be singular. Think of a model as 1 row in the DB. new_call::allI() = all rows. new_fall::find($id) == 1 row. I would change my model to NewCall but since you did it like that already you can do: Public function viewCall(new_calls, $newcall) return view('calls.viewCall')->with($newcall); . Now what you are type hinting at is $newcall is an instance of new_call. It is an eloquent.
– Brad Goldsmith
Nov 10 at 19:35
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
@Austin . Really read those laravel docs. Route model binding and type hinting are so important and help keep code clean/readable, which will go a long way. Good luck with your project.
– Brad Goldsmith
Nov 12 at 14:48
thanks for the info...am already on it
– Austin
Nov 12 at 16:41
add a comment |
up vote
0
down vote
I recommend too looking at naming convetions and route model binding and type hinting in the controller.
Then you'd have something like this:
public function viewCall(NewCall $newcall)
return view('calls.viewCall')->with($newcall);
and route would be like this:
Route::get('/calls/viewCall/newcall', 'CallsController@viewCall')->name('viewCall');
thanks for your response but it says "Class AppHttpControllersNewCall does not exist"
– Austin
Nov 9 at 15:45
So where you did: $new_call = new_calls::find($id); new_calls is your class. That is poor naming convention. Your model is new_calls and should be singular. Think of a model as 1 row in the DB. new_call::allI() = all rows. new_fall::find($id) == 1 row. I would change my model to NewCall but since you did it like that already you can do: Public function viewCall(new_calls, $newcall) return view('calls.viewCall')->with($newcall); . Now what you are type hinting at is $newcall is an instance of new_call. It is an eloquent.
– Brad Goldsmith
Nov 10 at 19:35
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
@Austin . Really read those laravel docs. Route model binding and type hinting are so important and help keep code clean/readable, which will go a long way. Good luck with your project.
– Brad Goldsmith
Nov 12 at 14:48
thanks for the info...am already on it
– Austin
Nov 12 at 16:41
add a comment |
up vote
0
down vote
up vote
0
down vote
I recommend too looking at naming convetions and route model binding and type hinting in the controller.
Then you'd have something like this:
public function viewCall(NewCall $newcall)
return view('calls.viewCall')->with($newcall);
and route would be like this:
Route::get('/calls/viewCall/newcall', 'CallsController@viewCall')->name('viewCall');
I recommend too looking at naming convetions and route model binding and type hinting in the controller.
Then you'd have something like this:
public function viewCall(NewCall $newcall)
return view('calls.viewCall')->with($newcall);
and route would be like this:
Route::get('/calls/viewCall/newcall', 'CallsController@viewCall')->name('viewCall');
answered Nov 9 at 15:22
Brad Goldsmith
1019
1019
thanks for your response but it says "Class AppHttpControllersNewCall does not exist"
– Austin
Nov 9 at 15:45
So where you did: $new_call = new_calls::find($id); new_calls is your class. That is poor naming convention. Your model is new_calls and should be singular. Think of a model as 1 row in the DB. new_call::allI() = all rows. new_fall::find($id) == 1 row. I would change my model to NewCall but since you did it like that already you can do: Public function viewCall(new_calls, $newcall) return view('calls.viewCall')->with($newcall); . Now what you are type hinting at is $newcall is an instance of new_call. It is an eloquent.
– Brad Goldsmith
Nov 10 at 19:35
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
@Austin . Really read those laravel docs. Route model binding and type hinting are so important and help keep code clean/readable, which will go a long way. Good luck with your project.
– Brad Goldsmith
Nov 12 at 14:48
thanks for the info...am already on it
– Austin
Nov 12 at 16:41
add a comment |
thanks for your response but it says "Class AppHttpControllersNewCall does not exist"
– Austin
Nov 9 at 15:45
So where you did: $new_call = new_calls::find($id); new_calls is your class. That is poor naming convention. Your model is new_calls and should be singular. Think of a model as 1 row in the DB. new_call::allI() = all rows. new_fall::find($id) == 1 row. I would change my model to NewCall but since you did it like that already you can do: Public function viewCall(new_calls, $newcall) return view('calls.viewCall')->with($newcall); . Now what you are type hinting at is $newcall is an instance of new_call. It is an eloquent.
– Brad Goldsmith
Nov 10 at 19:35
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
@Austin . Really read those laravel docs. Route model binding and type hinting are so important and help keep code clean/readable, which will go a long way. Good luck with your project.
– Brad Goldsmith
Nov 12 at 14:48
thanks for the info...am already on it
– Austin
Nov 12 at 16:41
thanks for your response but it says "Class AppHttpControllersNewCall does not exist"
– Austin
Nov 9 at 15:45
thanks for your response but it says "Class AppHttpControllersNewCall does not exist"
– Austin
Nov 9 at 15:45
So where you did: $new_call = new_calls::find($id); new_calls is your class. That is poor naming convention. Your model is new_calls and should be singular. Think of a model as 1 row in the DB. new_call::allI() = all rows. new_fall::find($id) == 1 row. I would change my model to NewCall but since you did it like that already you can do: Public function viewCall(new_calls, $newcall) return view('calls.viewCall')->with($newcall); . Now what you are type hinting at is $newcall is an instance of new_call. It is an eloquent.
– Brad Goldsmith
Nov 10 at 19:35
So where you did: $new_call = new_calls::find($id); new_calls is your class. That is poor naming convention. Your model is new_calls and should be singular. Think of a model as 1 row in the DB. new_call::allI() = all rows. new_fall::find($id) == 1 row. I would change my model to NewCall but since you did it like that already you can do: Public function viewCall(new_calls, $newcall) return view('calls.viewCall')->with($newcall); . Now what you are type hinting at is $newcall is an instance of new_call. It is an eloquent.
– Brad Goldsmith
Nov 10 at 19:35
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
thanks...I made some errors in my variable names and I have corrected them..my code now workes....thanks soo much... i really appreciate
– Austin
Nov 12 at 9:02
@Austin . Really read those laravel docs. Route model binding and type hinting are so important and help keep code clean/readable, which will go a long way. Good luck with your project.
– Brad Goldsmith
Nov 12 at 14:48
@Austin . Really read those laravel docs. Route model binding and type hinting are so important and help keep code clean/readable, which will go a long way. Good luck with your project.
– Brad Goldsmith
Nov 12 at 14:48
thanks for the info...am already on it
– Austin
Nov 12 at 16:41
thanks for the info...am already on it
– Austin
Nov 12 at 16:41
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228169%2fdisplaying-a-single-record-from-database-in-laravel%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Check my answer below and tell me if it works for you or not.
– rpm192
Nov 10 at 10:56
Add your
newcall.blade.php
andviewcall.blade.php
file and I will look at it.– rpm192
Nov 11 at 11:54
Did you updated your viewCall function as shown in my answer below?
– rpm192
Nov 11 at 16:48
yes...please view the updated version of my post..I included my foreach statement.. am still getting the
undefined variable calls
error– Austin
Nov 12 at 8:52