mercredi 22 janvier 2020

Laravel 5.2 Has Many Through, cant seem to specify foreign key on second table

I have 3 Models

Store
- store_id

BoltOn
- id
- name

StoreBoltOn
- store_id
- bolt_on_id

I'm trying to verify if Shop has a BoltOn with a given name.

But so far I'm unable to return all BoltOns from the Store model. I've tried

public function boltOns()
{
   return $this->hasManyThrough(BoltOn::class, StoreBoltOn::class, 'store_id', 'bolt_on_id', 'store_id');
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire