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 table 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