Edit relationship in table (belongtomany) in modal

Hello, I am looking for the best way to display in a table the list of a command's relationships to be able to edit them individually via a modal. The project I am working on includes orders, and within each order, there are several stays. So, the listcommande table has a relation like this: php Copier le code public function sejourscommande() { return $this->hasMany(Sejourscommande::class); } Currently, I am using split/stack to make the display of stays within the order collapsible. The display works fine, but I am not sure what solution to use to be able to edit the stays. My current code for displaying the table is as follows (I am using a view to loop through the stays, but I am not sure if this is the right solution):
Note that I thought about adding a button in my view to send the ID of the stay to edit, but as soon as I add a button in the Blade view, even with nothing inside and no class, I get a dozen errors in the console related to Alpine JS. But that is another problem I don't understand. Feel free to ask if you need further adjustments or additional details!
3 Replies
Dennis Koch
Dennis Koch5mo ago
The display works fine, but I am not sure what solution to use to be able to edit the stays
Is "sejourscommande" a "stay"? It's hard to tell with code in a foreign language. Why aren't you using a Relation Manager?
toeknee
toeknee5mo ago
I assume he wants a modal? I'd say #awcodes-table-repeater could be a good shout?
beuzathor
beuzathorOP5mo ago
Yes sejourscommande is a "stay". My goal is to have something like that in a table with for each line an edit button. Commande #123 (collapsed) Date de Commande: 2024-07-25 | id: 123 | ResteaPayer: 50.00 -------------------------------------------------------- | Prix Séjour | Assurance | Enfant | -------------------------------------------------------- | 500.00 | Oui | John Doe | | 350.00 | Non | Jane Smith | -------------------------------------------------------- It's something that must necessarily appear in all e-commerce panels where we display the customer's order, then we collapse and display the items ordered within the order with the quantity, price, etc... and at the end of the line, we add a button to modify the products
Want results from more Discord servers?
Add your server