public function form(Inventory $inventory, $variant = false)
    {
        return $this->form->of('inventory', function (FormGrid $form) use ($inventory, $variant) {
            if ($inventory->exists) {
                if ($variant === true) {
                    // If the inventory item exists and we're looking to create a form
                    // for a variant, we'll set the forms options accordingly.
                    $method = 'POST';
                    $url = route('maintenance.inventory.variants.store', [$inventory->getKey()]);
                    $form->submit = 'Create';
                } else {
                    // Otherwise we'll set the options to update the specified inventory item.
                    $method = 'PATCH';
                    $url = route('maintenance.inventory.update', [$inventory->getKey()]);
                    $form->submit = 'Save';
                }
            } else {
                $method = 'POST';
                $url = route('maintenance.inventory.store');
                $form->submit = 'Create';
            }

            $form->with($inventory);

            $form->attributes(compact('method', 'url'));

            $categories = Category::getSelectHierarchy('inventories');

            $metrics = Metric::all()->pluck('name', 'id');
            $metrics->put(0, 'None');

            $form->fieldset(function (Fieldset $fieldset) use ($categories, $metrics) {
                $fieldset
                    ->control('select', 'category')
                    ->value(function (Inventory $item) {
                        return $item->category_id;
                    })
                    ->options($categories);

                $fieldset
                    ->control('select', 'metric')
                    ->value(function (Inventory $item) {
                        return $item->metric_id;
                    })
                    ->options($metrics);

                $fieldset
                    ->control('input:text', 'name')
                    ->attributes([
                        'placeholder' => 'ex. Nails',
                    ]);

                $fieldset->control('input:textarea', 'description');
            });
        });
    }
public function form(Inventory $inventory, $variant = false)
    {
        return $this->form->of('inventory', function (FormGrid $form) use ($inventory, $variant) {
            if ($inventory->exists) {
                if ($variant === true) {
                    // If the inventory item exists and we're looking to create a form
                    // for a variant, we'll set the forms options accordingly.
                    $method = 'POST';
                    $url = route('maintenance.inventory.variants.store', [$inventory->getKey()]);
                    $form->submit = 'Create';
                } else {
                    // Otherwise we'll set the options to update the specified inventory item.
                    $method = 'PATCH';
                    $url = route('maintenance.inventory.update', [$inventory->getKey()]);
                    $form->submit = 'Save';
                }
            } else {
                $method = 'POST';
                $url = route('maintenance.inventory.store');
                $form->submit = 'Create';
            }

            $form->with($inventory);

            $form->attributes(compact('method', 'url'));

            $categories = Category::getSelectHierarchy('inventories');

            $metrics = Metric::all()->pluck('name', 'id');
            $metrics->put(0, 'None');

            $form->fieldset(function (Fieldset $fieldset) use ($categories, $metrics) {
                $fieldset
                    ->control('select', 'category')
                    ->value(function (Inventory $item) {
                        return $item->category_id;
                    })
                    ->options($categories);

                $fieldset
                    ->control('select', 'metric')
                    ->value(function (Inventory $item) {
                        return $item->metric_id;
                    })
                    ->options($metrics);

                $fieldset
                    ->control('input:text', 'name')
                    ->attributes([
                        'placeholder' => 'ex. Nails',
                    ]);

                $fieldset->control('input:textarea', 'description');
            });
        });
    }
public function form ( Inventory $ inventory , $ variant = false ) { return $ this -> form -> of ( 'inventory' , function ( FormGrid $ form ) use ( $ inventory , $ variant ) { if ( $ inventory -> exists ) { if ( $ variant === true ) { // If the inventory item exists and we're looking to create a form // for a variant, we'll set the forms options accordingly. $ method = 'POST' ; $ url = route ( 'maintenance.inventory.variants.store' , [ $ inventory -> getKey ( ) ] ) ; $ form -> submit = 'Create' ; } else { // Otherwise we'll set the options to update the specified inventory item. $ method = 'PATCH' ; $ url = route ( 'maintenance.inventory.update' , [ $ inventory -> getKey ( ) ] ) ; $ form -> submit = 'Save' ; } } else { $ method = 'POST' ; $ url = route ( 'maintenance.inventory.store' ) ; $ form -> submit = 'Create' ; } $ form -> with ( $ inventory ) ; $ form -> attributes ( compact ( 'method' , 'url' ) ) ; $ categories = Category :: getSelectHierarchy ( 'inventories' ) ; $ metrics = Metric :: all ( ) -> pluck ( 'name' , 'id' ) ; $ metrics -> put ( 0 , 'None' ) ; $ form -> fieldset ( function ( Fieldset $ fieldset ) use ( $ categories , $ metrics ) { $ fieldset -> control ( 'select' , 'category' ) -> value ( function ( Inventory $ item ) { return $ item -> category_id ; } ) -> options ( $ categories ) ; $ fieldset -> control ( 'select' , 'metric' ) -> value ( function ( Inventory $ item ) { return $ item -> metric_id ; } ) -> options ( $ metrics ) ; $ fieldset -> control ( 'input:text' , 'name' ) -> attributes ( [ 'placeholder' => 'ex. Nails' , ] ) ; $ fieldset -> control ( 'input:textarea' , 'description' ) ; } ) ; } ) ; }
Returns a new form for creating a new inventory item.

@param Inventory  $inventory
@param bool|false $variant

@return \Orchestra\Contracts\Html\Builder
Returns a new form for creating a new inventory item .