I see the type column in the schema, but does the column 'type' really exists in the table 'matchup_relations' ?
Since that is what it is complaining about, "Unknown column 'matchup_relations.type'"
Yep, that column definitely exists in the schema. If I change the query to this and run it via the CLI it runs as expected:
select count(*) from `matchup_relations` as `self_c0eb92e036f396b2ea0271d86e92ca90` where `self_c0eb92e036f396b2ea0271d86e92ca90`.`matchup_id` = `self_c0eb92e036f396b2ea0271d86e92ca90`.`id` and `matchups`.`deleted_at` is null and `self_c0eb92e036f396b2ea0271d86e92ca90`.`type` = 0) < 1
It appears Laravel has some issues with self referencing relationships in general. I tried simplifying it so I wouldn't need the relations table but that had its own slew of problems. Most the stuff works as I need with the MatchupRelations table, so I'll probably stick with this route and just avoid using has()
Eloquent is buggy when it comes to self-referencing belongsToMany. I'm going to fix that, but have no time right now.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community