fixed update missing values
This commit is contained in:
parent
87265191f2
commit
0f58e0f1eb
|
@ -64,9 +64,9 @@ class MediaController
|
|||
$rules = collect($media->model->getMediaCollection($media->collection_name)->runCallback('withPropertyValidation', $media->file_name))
|
||||
->mapWithKeys(fn ($rule, $key) => ["properties.{$key}" => $rule])->toArray();
|
||||
|
||||
$request->validate($rules);
|
||||
$validated = $request->validate($rules);
|
||||
|
||||
$media->update(['custom_properties' => $request->properties]);
|
||||
$media->update(['custom_properties' => data_get($validated, 'properties', [])]);
|
||||
|
||||
return MediaData::from($media);
|
||||
}
|
||||
|
|
|
@ -15,12 +15,15 @@ test('it updates a single files properties', function () {
|
|||
$response = $this->patchJson("/mediaupload/{$media->id}", [
|
||||
'properties' => [
|
||||
'test' => 'new',
|
||||
'missing' => 'value',
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
$this->assertEquals('new', $media->fresh()->getCustomProperty('test'));
|
||||
$this->assertEquals(null, $media->fresh()->getCustomProperty('missing'));
|
||||
$response->assertJsonPath('properties.test', 'new');
|
||||
$response->assertJsonMissingPath('properties.missing');
|
||||
});
|
||||
|
||||
test('it validates a single files properties', function () {
|
||||
|
|
Loading…
Reference in New Issue