Hello,
I'm trying to set up a hasOneThrough
relation on one table.
But Eloquent will not look it the two tables are the same and add an alias for one of the tables.
The table looks something like this:
Product table:
id
parent_id
....
Company_product
id
product_id
So the end query will look like this:
select `products`.*, `products`.`parent_id` as `laravel_through_key` from `products` inner join `products` on `products`.`parent_id` = `products`.`id` where `products`.`id` in (?)
So my question is, is there an option to tell Eloquent that is should an as
alias instead of the table name?
I know that I can eager loading them with chaining the relations but this would be better because I will not get any memory usage for the products that I don't even need.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community