Laravel Nova: TypeError: Невозможно прочитать свойство 'status' из неопределенного

Куча моих ресурсов Новы перестала работать. При попытке создать их, я получаю следующую ошибку в консоли:

Uncaught (in promise) TypeError: Cannot read property 'status' of undefined
at a.<anonymous> (app.js?id=7319bf5027431449796c:1)
at y (app.js?id=7319bf5027431449796c:1)
at Generator._invoke (app.js?id=7319bf5027431449796c:1)
at Generator.e.(anonymous function) [as next] (http://url/vendor/nova/app.js?id=7319bf5027431449796c:1:460720)
at o (app.js?id=7319bf5027431449796c:1)
at app.js?id=7319bf5027431449796c:1
at new Promise (<anonymous>)
at new t (app.js?id=7319bf5027431449796c:1)
at a.<anonymous> (app.js?id=7319bf5027431449796c:1)
at a.<anonymous> (app.js?id=7319bf5027431449796c:1)

Ничего не отображается в журнале ошибок вообще. Любые указатели, где я должен искать? Влияет только на одни ресурсы, другие работают нормально.

Изменить: Вот один из пострадавших ресурсов Нова:

<?php

namespace App\Nova;

use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\HasMany;
use Laravel\Nova\Fields\ID;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use Naxon\NovaFieldSortable\Concerns\SortsIndexEntries;
use Naxon\NovaFieldSortable\Sortable;

class Unterprodukt extends Resource
{
    use SortsIndexEntries;
    public static $defaultSortField = 'order';

    /**
     * The model the resource corresponds to.
     *
     * @var string
     */
    public static $model = 'App\Unterprodukt';

    /**
     * Get the displayble label of the resource.
     *
     * @return string
     */
    public static function label()
    {
        return 'Unterprodukte';
    }

    /**
     * Get the displayble singular label of the resource.
     *
     * @return string
     */
    public static function singularLabel()
    {
        return 'Unterprodukt';
    }

    /**
     * The logical group associated with the resource.
     *
     * @var string
     */
    public static $group = 'Versicherung';

    /**
     * The single value that should be used to represent the resource when being displayed.
     *
     * @var string
     */
    public static $title = 'name';

    /**
     * The columns that should be searched.
     *
     * @var array
     */
    public static $search = [
        'id',
        'name',
    ];

    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        return [
            ID::make()
                ->sortable()
                ->hideFromIndex(),

            Text::make('Name', 'name')
                ->sortable(),

            BelongsTo::make('Produkt', 'produkt', 'App\Nova\Produkt')
                ->sortable(),

            Sortable::make('Reihenfolge', 'id')
                ->sortable(),

            HasMany::make('Dokumente', 'dokumente', 'App\Nova\Dokument'),
        ];
    }

    /**
     * Get the cards available for the request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function cards(Request $request)
    {
        return [];
    }

    /**
     * Get the filters available for the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function filters(Request $request)
    {
        return [];
    }

    /**
     * Get the lenses available for the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function lenses(Request $request)
    {
        return [];
    }

    /**
     * Get the actions available for the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function actions(Request $request)
    {
        return [];
    }
}

1 ответ

Быстрое решение для этого заключается в следующем

Sortable::make('Order', 'id')->exceptOnForms()

У меня тоже была эта проблема, потому что у меня была несогласованность между полями новых и полями миграции.

Теперь есть еще один возможный способ исправить это:

php artisan nova:publish
php artisan view:clear

Проверьте эту проблему для получения дополнительных сведений: https://github.com/laravel/nova-issues/issues/1735

Другие вопросы по тегам