Closed
Description
Hi, I have a problem with laravel-mongo relationships, what I need is to make a one-to-many relationship where the id's are stored in the two tables.
Example:
class T1 extends Eloquent{ public function t2(){ return $this->hasMany('App\Models\T2'); } }
class T2 extends Eloquent{ public function t1(){ return $this->belongsTo('App\Models\T1'); } }
The code to Store:
$t1 = new T1;
$t1->save();
$t2 = new T2;
$t2->save();
$t1->t2()->save($t2);
$t1->save();
The id of T1 is stored on T2 as t1_id, but in the collection T1 does not appear t2_ids as an array of T2 id's.
I am doing something wrong? Is there a solution to my problem?