You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello guys, I`m having some trouble trying to figure out what is wrong with the code.
I have an hasOne relationship between Company and Partner.
Here are my Models:
App\Company.php
use Jenssegers\Mongodb\Eloquent\Model as Model;
class Company extends Model {
protected $collection = "company";
protected $primaryKey = "_id";
public function partner(){
return $this->hasOne(\App\Partner::class, "com_id");
}
}
App\Partner.php
use Jenssegers\Mongodb\Eloquent\Model as Model;
class Partner extends Model {
protected $collection = "partner";
protected $primaryKey = "_id";
protected $fillable = ["_id", "com_id", "email"];
}
If set foreign key from hasOne relationship pointing to primary key to model \App\Partner, It works like a charm.
But, If I set foreign key from relationship as com_id, returns NULL.
Both, _id and com_id have the same value.
Am I doing something wrong?
The text was updated successfully, but these errors were encountered:
Hello guys, I`m having some trouble trying to figure out what is wrong with the code.
I have an hasOne relationship between Company and Partner.
Here are my Models:
App\Company.php
App\Partner.php
If set foreign key from hasOne relationship pointing to primary key to model \App\Partner, It works like a charm.
But, If I set foreign key from relationship as
com_id
, returns NULL.Both,
_id
andcom_id
have the same value.Am I doing something wrong?
The text was updated successfully, but these errors were encountered: