编辑:

在novas ActionEvent.php类中我编辑了 forResourceUpdate 函数的两行字段和异常:

什么实际上很奇怪,现在我的资源已更新,但ACTION EVENT表中没有任何内容 .

public static function forResourceUpdate($user, $model)
{
    return new static([
        'batch_id' => (string) Str::orderedUuid(),
        'user_id' => $user->getKey(),
        'name' => 'Update',
        'actionable_type' => $model->getMorphClass(),
        'actionable_id' => $model->getKey(),
        'target_type' => get_class($model),
        'target_id' => $model->getKey(),
        'model_type' => get_class($model),
        'model_id' => $model->getKey(),
        'fields' => 'test',
        'status' => 'finished',
        'exception' => 'test',
    ]);
}

所以我刚刚安装了Nova设置了一些资源,它显示一切都很好,但是当我尝试更新它们中的任何一个时,我得到一个数据库错误,我无法将NULL插入 ACTION_EVENT.FIELDS .

https://nova.laravel.com/docs/1.0/actions/defining-actions.html#action-fields

Doc说我可以在Actions字段函数中定义一些字段,但我没有生成任何不想要的Action类 . 我认为它的某种默认动作记录?

我可以关掉它,还是我必须在某个地方添加一些字段?

<?php

namespace App\Nova;

use Laravel\Nova\Fields\ID;
use Illuminate\Http\Request;
use Laravel\Nova\Http\Requests\NovaRequest;

class Chain extends Resource
{

    public static $category = "Stammdaten";

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

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

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

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

    /**
     * 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 [];
    }
}

和模型:

class Chain extends Model
{
    use SoftDeletes;
    use ObservantTrait;
    use TranslationTrait;

    protected $primaryKey = 'partner_chain_id';
    protected $table = 'tbl_prm_partner_chain';
    public $sequence = 'seq_partner_chain_id';

    const CREATED_BY = 'insert_user';
    const CREATED_AT = 'insert_timestamp';

    const UPDATED_BY = 'update_user';
    const UPDATED_AT = 'update_timestamp';

    const DELETED_BY = 'delete_user';
    const DELETED_AT = 'delete_timestamp';

    protected $fillable = ['name_text', 'partner_type_id'];

    protected $dates = ['delete_timestamp', 'insert_timestamp'];

所有这一切都很简单,这就是为什么我现在没有线索我错了 .