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;

});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire