Back

When I have nested parameters in an url using route model binding, laravel will automatically populate the pivot on the child model. This even works on belongToMany relationships, with a custom pivot model. Sadly this breaks in livewire when rehydrating the child model.

Does anyone have a clever trick to hydrate the pivot again ?

3

128

  • No matching results...
  • Searching...

/ 1000

This is how I do it currently, but it seems kinda hacky :)

    public function hydrateFile()
{
$this->file = $this->customer->resolveChildRouteBinding('file', $this->file->uuid, 'uuid');
}

134

What makes it a bit annoying is that I can see livewire (or laravel) doing the queries I need, due to the url before hydration. Perhaps I need to find a way of extracting it from the url, and simply not mount it..

140

I ended up adding ulids to my pivot table and using that in the urls instead. That way it is waay simpler and I can load the file relationsship from there :)

137