Laravel-admin: 图片上传后,数据录入前能获得图片路径并编辑么?

Created on 29 Jun 2017  ·  1Comment  ·  Source: z-song/laravel-admin

$form->saving(function (Form $form) {
$form->logo = $this->uploadCdn($form->logo->getPathname());
});
我这边CDN是要求一个服务器绝对地址,这样报错,如果添加一个(/tmp/a.jpg),就可以,这种应该是上传后的图片地址吧,不知道在saving里面能获取到么

Most helpful comment

在模型里面添加保存前事件,就能在数据入库前修改相应数据:

public static function boot()
{
    parent::boot();

    static::saving(function ($model) {

        $model->logo = 'xxxxx';

    });
}

>All comments

在模型里面添加保存前事件,就能在数据入库前修改相应数据:

public static function boot()
{
    parent::boot();

    static::saving(function ($model) {

        $model->logo = 'xxxxx';

    });
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

xiaalngf picture xiaalngf  ·  3Comments

abufalbo picture abufalbo  ·  3Comments

greentornado picture greentornado  ·  3Comments

benny-sun picture benny-sun  ·  3Comments

piian picture piian  ·  3Comments