CristalTeam/php-api-wrapper

How can I eagerload an ApiRelation on an Eloquent model? Using the laravel bridge.

BramBosSoliede opened this issue · 1 comments

How can I eagerload an ApiRelation on an Eloquent model?

Im doing Offerte::with('klant')->get()

where "Offerte" is an eloquent model which uses "HasApiRelations"
"Offerte" has this method:

    public function klant(){
        return $this->belongsTo(Klant::class, 'klant_id');
    }

"Klant" extends ApiModel which in turn extends Cristal\ApiWrapper\Bridges\Laravel\Model

when I run Offerte::with('klant')->get() the response is: "Exception: Call to a member function addEagerConstraints() on array".

What am I doing wrong?

Hi @BramBosSoliede !

The "with" method in this package is currently not implemented. We are keeping this issue open. You are welcome to contribute if you want to implement this part yourself.

Camille,