$form->saving(function (Form $form) {
$form->logo = $this->uploadCdn($form->logo->getPathname());
});
我这边CDN是要求一个服务器绝对地址,这样报错,如果添加一个(/tmp/a.jpg),就可以,这种应该是上传后的图片地址吧,不知道在saving里面能获取到么
在模型里面添加保存前事件,就能在数据入库前修改相应数据:
public static function boot()
{
parent::boot();
static::saving(function ($model) {
$model->logo = 'xxxxx';
});
}
Most helpful comment
在模型里面添加保存前事件,就能在数据入库前修改相应数据: