jeudi 3 décembre 2015

Laravel Polymorphic Relationship trouble with Camel Case

In my polymorphic relationship, Laravel automatically converts my CamelCase id to an underscore. So when I try to get $store->product, I receive Column not found: 1054 Unknown column 'Products.location_id'.

My relationship looks like this.

Class Store() {
    public function product() {
        return $this->morphOne('App\Models\Product', 'locationId');
    }
}

Is there a way to not convert to underscore from CamelCase.

EDIT It appears it's actually adding "_id" to the end of the locationId. Any idea how to restrict/stop this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire