andersao / andersao/l5-repository

Is there a way to save instance with many relations?

Abierto
#395 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
PHP
Estrellas
4.2k
Forks
880
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I have two models ModelA and ModelB. The ModelA has many relation to ModelB. In ModelB i have field model_a_id. Getting relations for both models works fine, so relations os ok.

I try to store new instance of ModelA via api request with the next values:
```
...
somefield=somevalue
model_bs[1][somefield]=somevalue
model_bs[2][somefield]=somevalue
...
```
But got an exception:
```
(1/1) BadMethodCallException
Call to undefined method Illuminate\Database\Query\Builder::getForeignKey()
```

I know how to store it by native eloquent method, but is there are some way to do it via repository?

Thanx!

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.