vendredi 24 avril 2020

Laravel One to one relasionship showing property non object

I am trying basic laravel one to one relationship but there is an error. I have a table called posts(i will attach the image) and a Model Post.php. When I am trying to get the result from Route.php it is showing an error.MySql tableError message User.php

public function post()
{
    return $this->hasOne('App\Post');
}

Route.php

Route::get('/user/post', function () {
 $post = User::find(1)->post;
return $post;

});



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2S2nl6b
via IFTTT

Aucun commentaire:

Enregistrer un commentaire