laravel 5 show is returning empty query and not showing any data

laravel where not empty
laravel eloquent where not null or empty
laravel where column not empty
laravel empty query builder
laravel where not null and not empty
laravel first on empty collection
laravel check eloquent empty
check if model is empty laravel

i am new to laravel and i work on eloquent i want to send some data to view and show them like laravel documentation says so in my controller i wrote

public function show(PhoneBook $phoneBook)
    return view('',compact('phoneBook',$phoneBook));

and in the phonebook show view i wrote

 <strong>id</strong> {{ $phoneBook->id }}<br>
 <strong>calldate</strong> {{ $phoneBook->calldate }}<br>
 <strong>description</strong> {{ $phoneBook->description }}

any idea why i receive empty query with no result with no errors and just the titles with no result in front of them i thank you if you can help me with this


public function show($id)
    $phonebook = Phonebook::find($id);
    return view('',compact('phonebook'));


<strong>id</strong> {{ $phonebook->id }}<br>
<strong>calldate</strong> {{ $phonebook->calldate }}<br>
<strong>description</strong> {{ $phonebook->description }}

return rows in laravel that are not empty, How can I return rows in laravel that are not empty? For instance, what does this second line do other than trample on the query you ran in the first line? will also show the data type, like it will show NULL. print_r() just shows actual printable values. No that's not any better, arguably it's much worse. return rows in laravel that are not empty Posted 3 years ago by Bonboni I have the following output that I am getting from the laravel and I am inserting them in to selectbox as an option.

Try this:-

 return view('', compact('phoneBook'));

Eloquent returns empty collection, And in my controller, I'm trying to retrieve all the users progress with the I know i have data in the DB so thats not there reason either. Laravel is smart for figuring out the plural name but this may be confusing it. Posted 3 years ago by asdasdsa (level 5) There's no shortage of content at Laracasts. But for APIs it’s actually the most typical cause of errors – that consumer posts invalid data, and then stuff breaks. If we don’t put extra effort in catching bad data, then API will pass the back-end validation and throw just simple “Server error” without any details (which actually would mean DB query error).

You can try 2 ways below to send data from Controller to View:

return view('', compact('phoneBook'));


return view('')->with('phoneBook', $phoneBook);

Eloquent: Collections - Laravel, Likewise, if a map operation returns a collection that does not contain any Eloquent All Eloquent collections extend the base Laravel collection object; therefore, they inherit $users->modelKeys(); // [1, 2, 3, 4, 5]. makeVisible($​attributes). The makeVisible method makes attributes visible that are typically "​hidden" on each  The Laravel query builder uses PDO parameter binding to protect your application against SQL injection attacks. There is no need to clean strings being passed as bindings. PDO does not support binding column names. Therefore, you should never allow user input to dictate the column names referenced by your queries, including "order by" columns

Cache - Laravel, The Factory contract provides access to all cache drivers defined for your application. class UserController extends Controller { /** * Show a list of all users of the application. If the item does not exist in the cache, null will be returned. you may also use the global cache function to retrieve and store data via the cache. Laravel makes interacting with databases extremely simple across a variety of database backends using either raw SQL, the fluent query builder, and the Eloquent ORM. Currently, Laravel supports four databases: The database configuration for your application is located at config/database.php. In this file you may define all of your database

HTTP Requests - Laravel, You may also get the full URL and append query parameters. automatically be converted back to a Laravel response instance and be displayed by the framework. The has method returns true if the value is present and is not an empty string: You may also retrieve all of the input data as an array using the all method: How to get the query executed in Laravel 5 ? DB::getQueryLog returning empty array By default query log disabled in Laravel 5 of duplicate data What you want

mysql_fetch_field - Manual, (PHP 4, PHP 5). mysql_fetch_field — Get column information from a result and return as an echo "No information available<br />\n"; Simple function to display all data in a query. if(!empty($meta->table)) $fields[$index]=$meta->​table.'.'; Laravel - Guzzle not returning any data even though URL is correct Php Mysql Query not working properly From what you are showing I conclude that you don't

  • You need to give us your table content and structure, and the URL your accessing in order to help you
  • thanks you bas or Boss :) it did the job for me but i had another model Task which was working with the same code any idea what was the problem or which way is better to do it ? i was writing that code from this link and toturial
  • From that tutorial: "Resource controller uses the Route model binding, This means that you dont need to fetch the specified task by the id. Laravel will do it for you." There is no right or wrong. This answer is clear but requires more code. The tutorial contains a bit of magic but requires less code. Pick one, but be consistent!
  • @user3357687, if want to know why your code is not working, check this link
  • @bas Yes boss :) i would go for it :) and i will post what was the problem when ever i find any solotion for it ;)
  • Now you can access on blade template with $phoneBook
  • This is the correct answer for the code you provided, so something else is going on.
  • Can you please print $phoneBook output?
  • You should do, like this:- public function show($id) { $phoneBook = YourModel::find($id); return view('',compact('phoneBook')); } Anyway.
  • App\PhoneBook Object ( [fillable:protected] => Array ( [0] => description [1] => calldate [2] => rememberdate [3] => client_id ) [connection:protected] => [table:protected] => [primaryKey:protected] => id [keyType:protected] => int [incrementing] => 1 [with:protected] => Array ( ) [withCount:protected] => Array ( ) [perPage:protected] => 15 [exists] => [wasRecentlyCreated] => [attributes:protected] =>
  • may i please ask you to tell me what is the diffrence betwen compact('phoneBook') and compact('phoneBook', $phoneBook)
  • you are maybe mistake. If you use compact: you need only compact('phoneBook') OR If you use with: you must use ->with('phoneBook', $phoneBook)