Attaching + extra pivot info Hi all,
I have 3 models
Company
Partner
Application
now i have pivot table
application_company
here i have :
Application_id
Company_id
Partner_id
when i want in nova to attach a partner on a company i want also to fill the partner_id ?
in the models i have withPivot('partner_id')
You can give the user the option to define the partner_id By adding this method in your field array
//Nova/Company.php
BelongsToMany::make('Application')
->fields(function () {
return [
BelongsTo::make('Partner')
];
}),
@manojo123 Thanks but it dont work, i dont know if it is posible in nova to have 2 dropdowns for 2 relations?
it would be nice if this works.
return [
Text::make(__('Name'), 'name')->sortable(),
BelongsToMany::make('Applications')
->fields(function () {
return [
ID::make('partner_id'),
// Select::make('partner_id')->options([
// 'A' => 1,
// 'B' => 2,
// 'C' => 3,
// ])
];
}),
BelongsToMany::make('partners')
];
This works only i need to fill in the id by had, witch is nice for to test but my goal, so i tried with a select field, but when i select option A it will insert A into the database and not 1, witch result in a error. So i am looking now to make a nice dropdown.
Please sign in or create an account to participate in this conversation.