Laravel Nova动作场

时间:2018-10-17 07:10:53

标签: laravel laravel-nova

编辑:

在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

医生说我可以在“动作”字段函数中定义一些字段,但是我没有生成我不想要的任何动作类。我认为它是某种默认的操作日志记录?

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

<?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'];

就这么简单,这就是为什么我现在不知道哪里出问题了。

0 个答案:

没有答案