I'm trying to get all the items, in list(s) where the list has a user id.
Here are my models
Watchlist
public function books(){
return $this->hasMany('App\WatchedBooks');
}
public function user(){
return $this->belongsTo('App\User');
}
WatchedBooks
public function watchlist(){
return $this->belongsTo('App\Watchlist');
}
Query Gets all books in every list disregarding user ids and list ids
$Watchlists = WatchedBooks::all();
Currently gets all books regadless of userid.
I need all books in all of the users lists.
A user could have multiple lists List A List B
So something like All books from all lists where the list id is related to user id.
This is what the Watchlist DB looks like WatchlistDB
This is what the WatchedBooks DB looks like Books in watchlist
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2pqoxBP
via IFTTT
Aucun commentaire:
Enregistrer un commentaire