I have three tables (users,posts,and favourites). How do i get all the posts with laravel eloquent along with favourite posts and the name of the person who marked it as favourite.
Users id name email
Posts id name
Favourites id user_id post_id
This is what i am trying to do in controller but unabe to iterate it in view.
$posts = Post::with('favourites','users')->take(10)->get();
Please have a look into this link for more details.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire