orlyapps / nova-belongsto-depend

Larave Nova BelongsTo Field with Dependcy
MIT License
182 stars 65 forks source link

Can i set first array value to NULL? #41

Closed BenySLO closed 5 years ago

BenySLO commented 5 years ago

Resource: NovaBelongsToDepend::make('Chronometry Power Tow', 'chronometryPower', Chronometry::class) ->options(\App\Chronometry::filterChronometry(18))->nullable(), Model: public static function filterChronometry($category) { $get_chronometry_category = Chronometry::all() ->where('section_id', '=', $category); $chronometries = []; foreach ($get_chronometry_category as $each_chronometry) { $chronometries[] = $each_chronometry; } return $chronometries; }

So i am running this in model to populate my field, but I dont know how to allow a nullable value. if i push $chronometries[]=[]; it does not work

BenySLO commented 5 years ago

I will close this issue since i've probably misunderstood our code and the error occurred on saving. And now I'm using my own Select field which I custom populate.