public function form(WorkOrder $workOrder)
    {
        return $this->form->of('work-orders', function (FormGrid $form) use ($workOrder) {
            if ($workOrder->exists) {
                $method = 'PATCH';
                $url = route('maintenance.work-orders.update', [$workOrder->getKey()]);
                $form->submit = 'Save';
            } else {
                $method = 'POST';
                $url = route('maintenance.work-orders.store');
                $form->submit = 'Create';
            }

            $form->with($workOrder);

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

            $form->fieldset(function (Fieldset $fieldset) {
                $fieldset
                    ->control('select', 'category')
                    ->value(function (WorkOrder $workOrder) {
                        return $workOrder->category_id;
                    })
                    ->options(function () {
                        return Category::getSelectHierarchy('work-orders');
                    });

                $fieldset
                    ->control('select', 'location')
                    ->value(function (WorkOrder $workOrder) {
                        return $workOrder->location_id;
                    })
                    ->options(function () {
                        return Location::getSelectHierarchy();
                    });

                $fieldset
                    ->control('select', 'status')
                    ->options(function () {
                        $statuses = Status::all()->pluck('name', 'id');
                        $statuses[0] = 'None';

                        return $statuses;
                    });

                $fieldset
                    ->control('select', 'priority')
                    ->value(function (WorkOrder $workOrder) {
                        return $workOrder->priority_id;
                    })
                    ->options(function () {
                        $priorities = Priority::all()->pluck('name', 'id');
                        $priorities[0] = 'None';

                        return $priorities;
                    });

                $fieldset
                    ->control('select', 'assets[]')
                    ->label('Assets')
                    ->options(function () {
                        return Asset::all()->pluck('name', 'id');
                    })
                    ->attributes([
                        'class'    => 'select2',
                        'multiple' => true,
                    ]);

                $fieldset
                    ->control('input:text', 'subject')
                    ->attributes([
                        'placeholder' => 'ex. Worked on HVAC',
                    ]);

                $fieldset->control('input:textarea', 'description');
            });
        });
    }
public function form(WorkOrder $workOrder)
    {
        return $this->form->of('work-orders', function (FormGrid $form) use ($workOrder) {
            if ($workOrder->exists) {
                $method = 'PATCH';
                $url = route('maintenance.work-orders.update', [$workOrder->getKey()]);
                $form->submit = 'Save';
            } else {
                $method = 'POST';
                $url = route('maintenance.work-orders.store');
                $form->submit = 'Create';
            }

            $form->with($workOrder);

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

            $form->fieldset(function (Fieldset $fieldset) {
                $fieldset
                    ->control('select', 'category')
                    ->value(function (WorkOrder $workOrder) {
                        return $workOrder->category_id;
                    })
                    ->options(function () {
                        return Category::getSelectHierarchy('work-orders');
                    });

                $fieldset
                    ->control('select', 'location')
                    ->value(function (WorkOrder $workOrder) {
                        return $workOrder->location_id;
                    })
                    ->options(function () {
                        return Location::getSelectHierarchy();
                    });

                $fieldset
                    ->control('select', 'status')
                    ->options(function () {
                        $statuses = Status::all()->pluck('name', 'id');
                        $statuses[0] = 'None';

                        return $statuses;
                    });

                $fieldset
                    ->control('select', 'priority')
                    ->value(function (WorkOrder $workOrder) {
                        return $workOrder->priority_id;
                    })
                    ->options(function () {
                        $priorities = Priority::all()->pluck('name', 'id');
                        $priorities[0] = 'None';

                        return $priorities;
                    });

                $fieldset
                    ->control('select', 'assets[]')
                    ->label('Assets')
                    ->options(function () {
                        return Asset::all()->pluck('name', 'id');
                    })
                    ->attributes([
                        'class'    => 'select2',
                        'multiple' => true,
                    ]);

                $fieldset
                    ->control('input:text', 'subject')
                    ->attributes([
                        'placeholder' => 'ex. Worked on HVAC',
                    ]);

                $fieldset->control('input:textarea', 'description');
            });
        });
    }
public function form ( WorkOrder $ workOrder ) { return $ this -> form -> of ( 'work-orders' , function ( FormGrid $ form ) use ( $ workOrder ) { if ( $ workOrder -> exists ) { $ method = 'PATCH' ; $ url = route ( 'maintenance.work-orders.update' , [ $ workOrder -> getKey ( ) ] ) ; $ form -> submit = 'Save' ; } else { $ method = 'POST' ; $ url = route ( 'maintenance.work-orders.store' ) ; $ form -> submit = 'Create' ; } $ form -> with ( $ workOrder ) ; $ form -> attributes ( compact ( 'method' , 'url' ) ) ; $ form -> fieldset ( function ( Fieldset $ fieldset ) { $ fieldset -> control ( 'select' , 'category' ) -> value ( function ( WorkOrder $ workOrder ) { return $ workOrder -> category_id ; } ) -> options ( function ( ) { return Category :: getSelectHierarchy ( 'work-orders' ) ; } ) ; $ fieldset -> control ( 'select' , 'location' ) -> value ( function ( WorkOrder $ workOrder ) { return $ workOrder -> location_id ; } ) -> options ( function ( ) { return Location :: getSelectHierarchy ( ) ; } ) ; $ fieldset -> control ( 'select' , 'status' ) -> options ( function ( ) { $ statuses = Status :: all ( ) -> pluck ( 'name' , 'id' ) ; $ statuses [ 0 ] = 'None' ; return $ statuses ; } ) ; $ fieldset -> control ( 'select' , 'priority' ) -> value ( function ( WorkOrder $ workOrder ) { return $ workOrder -> priority_id ; } ) -> options ( function ( ) { $ priorities = Priority :: all ( ) -> pluck ( 'name' , 'id' ) ; $ priorities [ 0 ] = 'None' ; return $ priorities ; } ) ; $ fieldset -> control ( 'select' , 'assets[]' ) -> label ( 'Assets' ) -> options ( function ( ) { return Asset :: all ( ) -> pluck ( 'name' , 'id' ) ; } ) -> attributes ( [ 'class' => 'select2' , 'multiple' => true , ] ) ; $ fieldset -> control ( 'input:text' , 'subject' ) -> attributes ( [ 'placeholder' => 'ex. Worked on HVAC' , ] ) ; $ fieldset -> control ( 'input:textarea' , 'description' ) ; } ) ; } ) ; }
Returns a new form for work orders.

@param WorkOrder $workOrder

@return \Orchestra\Contracts\Html\Builder
Returns a new form for work orders .