Closed nikrovir closed 5 months ago
My pull request adds syntactic sugar like the one used in eloquent builder to allow the when() method to be used.
Example:
$model->addMedia($file) ->preservingOriginal(false) ->when(in_array($file->getMimeType(), $availableMimeTypes), function (FileAdder $fileAdder) { $fileAdder->withCustomProperties([ 'property' => 'value', ]); })->toMediaCollection();
Instead:
$media = $model->addMedia($file)->preservingOriginal(false); if (in_array($file->getMimeType(), $availableMimeTypes)) { $media->withCustomProperties([ 'property' => 'value', ]); } $media->toMediaCollection();
Could you also add a test for this and add an example to the readme?
Closing due to inactivity.
My pull request adds syntactic sugar like the one used in eloquent builder to allow the when() method to be used.
Example:
Instead: