anditsung
1 week ago
1142
4
Nova

Model with BelongsTo and BelongsToMany

Posted 1 week ago by anditsung

i have a Resource with this fields

public function fields(Request $request) { return [ BelongsTo::make('Material'),

        BelongsToMany::make('Materials')
            ->fields(function() {
                return [
                    Number::make('Quantity'),

                    Boolean::make('Need Test'),
                ];
            })
    ];
}

MODEL public function material() : BelongsTo { return $this->belongsTo(Material::class); }

public function materials() : BelongsToMany
{
    return $this->belongsToMany(Material::class, 'warehouse_chemical_formula_materials');
}

when i try to attach material i only get 1 input for material selection i cant add other info like quantity and need test.

when i remove BelongsTo::make('Material'),

i can add that field. anyone know how to fix this issue?

Please sign in or create an account to participate in this conversation.