I'm trying to implement a blog type website where the user can rate the posts. So the relationship is like this:
Blog -> blog_links; To Many fk = blog_id
User -> blog_links; To Many fk = user_id
I've tried these solutions and each time get a different error:
User::hasManyThrough(Blog::class, BlogLink::class);
That didn't work, so I tried query scope:
scopeWithLinksAndResorts($query) {
return $query->with(['resorts' => function($q) {
$q->ordered()->withLinks();
}]);
}
That doesn't seem to return any results. So I'm not sure what I'm doing wrong here. And here's a table example:
blogs
id Title Text
1 Test This is a test blog
users
id email
1 test@test.com
blog_links
id blog_id user_id rating
1 1 1 4
Now from this I want to get the blogs the user has rated and their rating. But as I said I get no results. Anyone able to help?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lhdWHE
via IFTTT
Aucun commentaire:
Enregistrer un commentaire