I'm having trouble with the belongsToMany relationship from Jensseger's mongodb laravel package.
It just won't give me any results and after hours of testing, I'm kind of puzzled.
Using the embedsMany, seems to work for what I'm trying to do, but it won't let me associate another relationship to it after. Here's a more clear example below.
User Collection
{
"id" : 1,
"name" : "bla",
...
...
"isFriendsWith" : [2,3],
"otherLargeDocument_id": 1
},
{
...
}
User Model
use Jenssegers\Mongodb\Eloquent\Model as Model;
class User extends Model{
public function friends(){
return $this->belongsToMany('App\User', null, 'id', 'isFriendsWith');
}
public function otherRelation(){
return $this->belongsTo('App\Other', 'otherLargeDocument_id', 'id');
}
}
Displaying data
@foreach(App\User::find(1)->friends()->get() as $friend){
@endforeach
Thanks for the help!
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2jOhn5Q
via IFTTT
Aucun commentaire:
Enregistrer un commentaire