Search code examples
laravellaravel-nova

How to ignore field from database operation in Laravel Nova


I am developing a Web Application using Laravel Nova. Laravel Nova is quite new. I am now having problem with database relationship and Fields. I like to ignore a field from database operations. This is my scenario.

In the Job resource, I have this fields method

public function fields(Request $request)
    {
        return [
            ID::make()->sortable(),
            Text::make('Name', 'name'),
            Text::make('Email', 'email'),
            Select::make('Contract Types')->options($array_of_options)//I want to ignore this field
        ];
    }

As you can see, the last field is Contract Types.

When I create a new job from Dashboard, it is throwing error because there is no contract_types column on the Job model. I like to ignore that field from database operation. How can I get it?


Solution

  • According to the docs https://nova.laravel.com/docs/1.0/resources/fields.html#showing-hiding-fields

    Select::make('Contract Types')
        ->options($array_of_options)
        ->hideWhenCreating()