In laravel\backpack (https://backpackforlaravel.com/)! I'm trying to create store customer data with users attached. To do this I figured I'd use a many 2 many relationship with a pivot table.
Since i will needs more pivots, i thought it be clever to have a table that stores pivot data like customer_id
model_type
moderl_id
In other words a polymorphic pivot table.
This solution didn't quite work: BACKPACK Laravel manage extra columns in pivot table in a many-to-many relationship using Backpack CRUD
I also trying to link this to a field like this:
[
'name' => 'users',
'type' => 'select2_from_ajax_multiple_pivot',
'label' => "Overige Contactpersonen",
'entity' => 'users',
'attribute' => 'fullname',
'box' => 'Contactpersonen',
'data_source' => url('api/customers'),
'placeholder' => 'Koper',
'pivotFieldsLabel' => ['Spekkies'],
'pivot' => true,
'pivotFields' => [
'model_type' => 'user'
],
'model' => BackpackUser::class,
'minimum_input_length' => 2,
],
So far it only results in a pivot table where the customer_id
and the model_id
are stored.