2

编辑:

在 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

文档说我可以在 Actions fields 函数中定义一些字段,但我没有生成任何我不想生成的 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'];

这一切都很简单,这就是为什么我现在没有线索我哪里出错了。

4

0 回答 0