Im running the latest version of Laravel. I am trying to set up relationships with tables but I seem to always get some sort of error. The data that I want to be displayed is displayed but then under everything there is a big error saying:
ErrorException in routes.php line 26: Trying to get property of non-object
In my routes.php file this is the code:
Route::get('select', function() {
$users = App\UserInfo::all();
foreach ($users as $u) {
echo $u->userID.' USERNAME: '.$u->userData->username.'<br/>';
echo $u->userOption->dis_joindate.'<br/>'; // Line 26
}
});
Line 25 seems to work fine printing no errors, though the next line gives the object error.
This is my UserInfo Model php file:
And this is my Options Model php file:
All that my database supplies (in the useroptions table) is and id, userID, dis_joindate, dis_location, dis_posts and dis_likes. And the last 4 colums just give text.
This is the image of the output on the page when all this is ran:
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire