I'm trying to learn eloquent relationships. My relation is something like: Users hasMany posts and a post belongs to a user.
when I run my queries in tinker it shows errors.
Error: Exception with message 'Property [post] does not exist on this collection instan
ce.'
$user->new User;
$user->all(); //Displays all the users
but i cannot do
$user->all()->posts;
How can I achieve something like I want to have the users associated with posts or precisely I want users who have written posts.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire