$form->multipleImage('images')->sortable()->compress(['width' => 750,'quality' => 90,])->uniqueName()标签:laravel,return,form,admin,image,value,url,images,multiple From: https://www.cnblogs.com/paulversion/p/16924205.html
->saveAsString()->saving(function ($value)use($form){
if ($form->isEditing() && request()->filled('_file_del_')) {
if (ChapterImage::where('image_url', request()->input('_file_del_'))->delete() > 0) {
return $form->response()->success('删除成功');
}
return $form->response()->error('删除失败');
} else {
if ($value) {
$form->saved(function ()use($value,$form){
$data = json_decode($value);
ChapterImage::whereIn('image_url', $data)->delete();//delete all
$insertData = [];
foreach ($data as $item) {
$insertData[] = [
'image_url' => $item,
'chapter_id' => $form->repository()->model()->id,
];
}
\DB::table('chapter_images')->insert($insertData);
});
}
return $form->response()->success('成功');
}
})->customFormat(function ($value){
if (!$value) {
return;
}
return array_column($value,'image_url');
});