diff --git a/src/CollectionExtension.php b/src/CollectionExtension.php index a268d6f..a3aa67e 100644 --- a/src/CollectionExtension.php +++ b/src/CollectionExtension.php @@ -8,7 +8,8 @@ class CollectionExtension { public function boot(): void { - MediaCollection::mixin(new class() { + MediaCollection::mixin(new class() + { public function forceFileName() { return fn ($callback) => $this->registerCustomCallback('forceFileName', $callback); @@ -86,7 +87,7 @@ class CollectionExtension 'after' => fn ($event) => true, 'destroyed' => fn ($event) => true, 'storing' => fn ($adder, $name) => $adder, - 'withDefaultProperties' => fn ($path) => [], + 'withDefaultProperties' => fn ($path, $pathinfo) => [], 'withPropertyValidation' => fn ($path) => [], 'withFallback' => fn ($parent) => null, ]); diff --git a/src/MediaController.php b/src/MediaController.php index 911a56b..6c44b61 100644 --- a/src/MediaController.php +++ b/src/MediaController.php @@ -54,7 +54,7 @@ class MediaController $adder = $this->fileAdderFromData($model, $c['content'], $collection) ->usingName($basename) ->usingFileName($path) - ->withCustomProperties($collection->runCallback('withDefaultProperties', $path)); + ->withCustomProperties($collection->runCallback('withDefaultProperties', $path, $pathinfo)); return tap( $collection->runCallback('storing', $adder, $path)->toMediaCollection($collection->name), diff --git a/tests/Models/Post.php b/tests/Models/Post.php index 5b18122..225366d 100644 --- a/tests/Models/Post.php +++ b/tests/Models/Post.php @@ -56,7 +56,7 @@ class Post extends Model implements HasMedia Event::dispatch(new MediaStored($media)); }); - $this->addMediaCollection('multipleProperties')->singleFile()->withDefaultProperties(fn ($path) => [ + $this->addMediaCollection('multipleProperties')->singleFile()->withDefaultProperties(fn ($path, $pathinfo) => [ 'test' => Str::camel($path), ])->withPropertyValidation(fn ($path) => [ 'test' => 'string|max:10',