morphedByMany in RelationManager error without allowDuplicates

Hi, RelationManager support morphedByMany relationship with pivot table ?
1 Reply
psycho_cfh
psycho_cfhOP12mo ago
i found this problem, when i use the AttachAction on Relation Manager if i don't use allowDuplicates() give me an query error. SQLSTATE[42S22]: Column not found: 1054 Unknown column 'order_items.product_id' in 'where clause'
select distinct `products`.* from `products` left join `order_items` on `products`.`id` = `order_items`.`order_item_id` where (`products`.`name` like %f%) and not exists (select * from `orders` inner join `order_items` on `orders`.`id` = `order_items`.`order_item_id` where `products`.`id` = `order_items`.`product_id` and `order_items`.`order_item_type` = App\Models\Order and `orders`.`id` = 3) order by `products`.`name` asc limit 50
select distinct `products`.* from `products` left join `order_items` on `products`.`id` = `order_items`.`order_item_id` where (`products`.`name` like %f%) and not exists (select * from `orders` inner join `order_items` on `orders`.`id` = `order_items`.`order_item_id` where `products`.`id` = `order_items`.`product_id` and `order_items`.`order_item_type` = App\Models\Order and `orders`.`id` = 3) order by `products`.`name` asc limit 50
the correct query shoul be
select distinct `products`.* from `products` left join `order_items` on `products`.`id` = `order_items`.`order_item_id` where (`products`.`name` like %f%) and not exists (select * from `orders` inner join `order_items` on `orders`.`id` = `order_items`.`order_item_id` where `products`.`id` = `order_items`.`order_item_id` and `order_items`.`order_item_type` = App\Models\Product and `orders`.`id` = 3) order by `products`.`name` asc limit 50
select distinct `products`.* from `products` left join `order_items` on `products`.`id` = `order_items`.`order_item_id` where (`products`.`name` like %f%) and not exists (select * from `orders` inner join `order_items` on `orders`.`id` = `order_items`.`order_item_id` where `products`.`id` = `order_items`.`order_item_id` and `order_items`.`order_item_type` = App\Models\Product and `orders`.`id` = 3) order by `products`.`name` asc limit 50
can someone help me please
Want results from more Discord servers?
Add your server