fix: 🐛 resolve error when image is selected and saved
This commit is contained in:
parent
42d09e8965
commit
74853687f3
5 changed files with 18 additions and 5 deletions
|
|
@ -219,7 +219,7 @@ abstract class UpdateMiniCrudRequest extends FormRequest
|
|||
if (Arr::exists($this->input("data.$iptName.value"), 'picture')) {
|
||||
$rules = array_merge($rules, [
|
||||
"data.$iptName.value.picture" => "required|array",
|
||||
"data.$iptName.value.picture.path" => "required|image|mimes:png,jpg,jpeg|dimensions:width=620,height=348",
|
||||
"data.$iptName.value.picture.path" => "required",
|
||||
"data.$iptName.value.picture.alt" => "required|string|between:3,255",
|
||||
"data.$iptName.value.picture.title" => "required|string|between:3,255",
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -184,6 +184,13 @@ trait MiniCrudModel
|
|||
}
|
||||
break;
|
||||
case InputType::selectImageVideo->value:
|
||||
if (isset($data[$o]['value']['picture']) && $data[$o]['value']['picture']['path'] instanceof \Illuminate\Http\UploadedFile) {
|
||||
$data[$o]['value']['picture']['path'] = \preg_replace(
|
||||
'/^\/|^/',
|
||||
'',
|
||||
FileStorageHelper::storeFile($this, $data[$o]['value']['picture']['path'], true)
|
||||
);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new \ErrorException(sprintf(
|
||||
|
|
|
|||
|
|
@ -293,6 +293,10 @@ return new class extends Migration
|
|||
'inputType' => InputType::selectImageVideo->value,
|
||||
'value' => '',
|
||||
'validate' => 'required|array',
|
||||
'dimensions' => [
|
||||
'width' => 620,
|
||||
'height' => 348
|
||||
],
|
||||
'required' => true
|
||||
],
|
||||
'discover_title_1' => [
|
||||
|
|
|
|||
|
|
@ -257,6 +257,8 @@
|
|||
'name' => $k,
|
||||
'value' => old("data.{$k}.value", $input['value'] ?? null),
|
||||
'required' => isset($input['required']) ? !empty($input['required']) : true,
|
||||
'width' => $input['dimensions']['width'],
|
||||
'height' => $input['dimensions']['height'],
|
||||
'model' => $model ?? null,
|
||||
'helper' =>
|
||||
__('crud.minicrud.text_warning') .
|
||||
|
|
|
|||
|
|
@ -89,13 +89,13 @@
|
|||
@include('bo.partials.inputs.varchar-picture', [
|
||||
'id' => sprintf("%sPicture", $id),
|
||||
'name' => "data[$name][value][picture][path]",
|
||||
'width' => 500,
|
||||
'height' => 500,
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'model' => $model ?? null,
|
||||
'value' => $model->data[$name]['value']['picture']['path'] ?? null,
|
||||
'helper' => __('crud.minicrud.dimensions_must_be', [
|
||||
'width' => 500,
|
||||
'height' => 500,
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
]),
|
||||
'required' => true,
|
||||
'preview' => false,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue