I have a problem where I'm not able to access relations I have made on my resource. I made a resource called tag-submissions and one submission is related to a single tag and user. If I then try to access the relation, making sure I include submissions.user when getting the tag:
app.store.find('tags', this.attrs.tag_id, { include: ['submissions', 'submissions.user'] }).then(tag => {
this.tagModel = tag;
})
and then do:
this.submissions = this.attrs.tagModel.submissions();
console.log(this.submissions[0].user())
It logs the following:
ƒ (){const e=this.data.relationships?.[t]?.data;if(e&&e instanceof Array)throw new Error(`Relationship ${t} on model ${this.data.type} is plural, so the hasOne method cannot be used to access it.`);ret…
Even tho, it should log the user object. I'm wondering how I can fix this. I will also send all the relations I have defined:
In the front-end model:
user() {
return Model.hasOne<User>('user');
}
The back-end resource:
Schema\Relationship\ToOne::make('user')
->type('users')
->includable(),
And the back-end model:
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
Lastly the database has a submission with a valid user_id and logging just this.submissions in the front end shows the user relation just not included.