Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

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'"

0

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()

Last updated 9 years ago.
0

Eloquent is buggy when it comes to self-referencing belongsToMany. I'm going to fix that, but have no time right now.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

derekaug derekaug Joined 14 Jan 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.