Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel Nova:选择字段中的默认选择选项_Laravel_Laravel Nova - Fatal编程技术网

Laravel Nova:选择字段中的默认选择选项

Laravel Nova:选择字段中的默认选择选项,laravel,laravel-nova,Laravel,Laravel Nova,我需要在“选择”字段中显示所选的用户角色是否有任何方法可以传递值,并且默认情况下会使用“显示标签”选择该值。问题已完全解决,解决方案是: Select::make('My type', 'type') ->options(\App\Models\Cost::TYPE) ->sortable() ->resolveUsing(function () { return $this->type ?? 'expense'; })

我需要在“选择”字段中显示所选的用户角色是否有任何方法可以传递值,并且默认情况下会使用“显示标签”选择该值。

问题已完全解决,解决方案是:

Select::make('My type', 'type')
    ->options(\App\Models\Cost::TYPE)
    ->sortable()
    ->resolveUsing(function () {
        return $this->type ?? 'expense';
    })
    ->displayUsingLabels()
    ->rules('required'),