Too many queries n-n relation #352
-
|
Hello there, I'm fairly new to Backpack so please bear with me. I have setup everything like stated in the doc : On the ProductCrudController setupCreateOperation And it works fine but : I tried eager loading in different places But it doesn't seems to make a difference... I'm probably missing something. Any ideas on how to optimize this ? 2°) Additionally how do you validate the extra pivot field with Backpack ? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
|
Hello @imasubmarine Thanks for the suggestion about the queries. Actually I started working on a branch to solve that issue. I haven't created the PR yet, but I hope to be able to create it by the end of this week, that will drastically reduce the query number on relations and more. About the validation, you can validate in the fields by defining Cheers |
Beta Was this translation helpful? Give feedback.
-
|
Hello @pxpm I have another question regarding the same context. (Although it would be probably better to open a new thread) When i add a new item with the Field relationship (n-n) : So either it is not permitted by your component and Backpack should raise an error. Any ideas on how i can solve this ? Thanks |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for answer @pxpm ! I totally agree with your User, Role example. But it doesn't match my case. My primary goal was to use the right field in the Product CRUD Controller. I agree i could rethink my relations in a more semantically meaningfull way like so: Why would i want duplicates in the pivot table ? 1°) a Product is a type of Sofa Design
2°) I didn't read anything that says you cannot have duplicate in a pivot table And it would work Actually Nova addresses that: (but i'll stick to Backpack ;-)) So i'm confused and i agree it might be a Laravel ambiguity. With all those new elements what would be your advice to solve my case with current Backpack version ? Thanks |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @pxpm ! Following your advice here is what i came up with for the ProductCrudController: While this seems to work fine for me with the Relationship PRO field, there might be loopholes. Cheers |
Beta Was this translation helpful? Give feedback.
Hello @imasubmarine
Thanks for the suggestion about the queries. Actually I started working on a branch to solve that issue.
I haven't created the PR yet, but I hope to be able to create it by the end of this week, that will drastically reduce the query number on relations and more.
About the validation, you can validate in the fields by defining
'validationRules' => 'required|smt_else', or in theRequestif you are already using a Request class in that form with:'pictos.*.name_of_the_field' => rulesCheers