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!
Was this page helpful?