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', 'id', 'store_id')->toSql();
}
Results in the following SQL join statement.
select * from `bolt_on` inner join `store_bolt_on` on `store_bolt_on`.`id` = `bolt_on`.`id` where `store_bolt_on`.`store_id` = ?"
As you can see this needs to be
select * from `bolt_on` inner join `store_bolt_on` on `store_bolt_on`.`bolt_on_id` = `bolt_on`.`id` where `store_bolt_on`.`store_id` = ?"
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire