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

تعليقات

المشاركات الشائعة من هذه المدونة

I am unable to figure out how to create payment collection request, after a form has been submitted in laravel

laravel, mysql transaction not working after failed one time