Compare commits
	
		
			No commits in common. "0c10472e2ef1640f55820587c24e7b91f1e92788" and "c385212f7563eba95d27b9b54469501a8104655e" have entirely different histories.
		
	
	
		
			0c10472e2e
			...
			c385212f75
		
	
		| 
						 | 
					@ -45,12 +45,10 @@ class MediaController
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $medias = collect($content)->map(function ($c) use ($collection, $model) {
 | 
					        $medias = collect($content)->map(function ($c) use ($collection, $model) {
 | 
				
			||||||
            $pathinfo = pathinfo($c['name']);
 | 
					            $pathinfo = pathinfo($c['name']);
 | 
				
			||||||
            $basename = $collection->runCallback('forceFileName', $model, $pathinfo['filename']);
 | 
					            $path = $collection->runCallback('forceFileName', $model, $pathinfo['filename']).'.'.$pathinfo['extension'];
 | 
				
			||||||
            $path = $basename.'.'.$pathinfo['extension'];
 | 
					            Storage::disk('public')->put($path, base64_decode($c['content']));
 | 
				
			||||||
            $adder = $model
 | 
					            $adder = $model
 | 
				
			||||||
                ->addMediaFromBase64($c['content'])
 | 
					                ->addMedia(Storage::disk('public')->path($path))
 | 
				
			||||||
                ->usingName($basename)
 | 
					 | 
				
			||||||
                ->usingFileName($path)
 | 
					 | 
				
			||||||
                ->withCustomProperties($collection->runCallback('withDefaultProperties', $path));
 | 
					                ->withCustomProperties($collection->runCallback('withDefaultProperties', $path));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return tap(
 | 
					            return tap(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,8 +27,6 @@ class MediaData extends Data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public string $fileName;
 | 
					    public string $fileName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public string $mimeType;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    #[MapInputName('custom_properties')]
 | 
					    #[MapInputName('custom_properties')]
 | 
				
			||||||
    public array $properties;
 | 
					    public array $properties;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -65,7 +63,6 @@ class MediaData extends Data
 | 
				
			||||||
            'file_name' => pathinfo($default[0], PATHINFO_BASENAME),
 | 
					            'file_name' => pathinfo($default[0], PATHINFO_BASENAME),
 | 
				
			||||||
            'properties' => [],
 | 
					            'properties' => [],
 | 
				
			||||||
            'fallback' => true,
 | 
					            'fallback' => true,
 | 
				
			||||||
            'mime_type' => Storage::disk($default[1])->mimeType($default[0]),
 | 
					 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,7 +31,7 @@ class ServiceProvider extends BaseServiceProvider
 | 
				
			||||||
    protected function routeGroup(): array
 | 
					    protected function routeGroup(): array
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return [
 | 
					        return [
 | 
				
			||||||
            'middleware' => config('media-library.middleware'),
 | 
					            'middleware' => config('medialibrary-helper.middleware'),
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,7 +29,6 @@ test('it gets media for single', function () {
 | 
				
			||||||
    $response->assertJsonPath('id', $media->id);
 | 
					    $response->assertJsonPath('id', $media->id);
 | 
				
			||||||
    $response->assertJsonPath('properties.test', 'old');
 | 
					    $response->assertJsonPath('properties.test', 'old');
 | 
				
			||||||
    $response->assertJsonPath('fallback', false);
 | 
					    $response->assertJsonPath('fallback', false);
 | 
				
			||||||
    $response->assertJsonPath('mime_type', 'application/pdf');
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('it checks for authorization', function () {
 | 
					test('it checks for authorization', function () {
 | 
				
			||||||
| 
						 | 
					@ -65,7 +64,6 @@ test('test it gets conversions for single media', function () {
 | 
				
			||||||
test('test it gets default single media', function () {
 | 
					test('test it gets default single media', function () {
 | 
				
			||||||
    $this->auth()->registerModel();
 | 
					    $this->auth()->registerModel();
 | 
				
			||||||
    $post = $this->newPost();
 | 
					    $post = $this->newPost();
 | 
				
			||||||
    Storage::disk('public')->put('default.jpg', $this->jpgFile()->getContent());
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $response = $this->getJson("/mediaupload/post/{$post->id}/conversionsWithDefault");
 | 
					    $response = $this->getJson("/mediaupload/post/{$post->id}/conversionsWithDefault");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,5 +73,4 @@ test('test it gets default single media', function () {
 | 
				
			||||||
    $response->assertJsonPath('name', 'default');
 | 
					    $response->assertJsonPath('name', 'default');
 | 
				
			||||||
    $response->assertJsonPath('file_name', 'default.jpg');
 | 
					    $response->assertJsonPath('file_name', 'default.jpg');
 | 
				
			||||||
    $response->assertJsonPath('fallback', true);
 | 
					    $response->assertJsonPath('fallback', true);
 | 
				
			||||||
    $response->assertJsonPath('mime_type', 'image/jpeg');
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,6 +39,6 @@ class MiddlewareTest extends TestCase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected function defineEnvironment($app)
 | 
					    protected function defineEnvironment($app)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $app['config']->set('media-library.middleware', ['web', 'auth:web']);
 | 
					        $app['config']->set('medialibrary-helper.middleware', ['web', 'auth:web']);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -82,6 +82,6 @@ class TestCase extends BaseTestCase
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected function defineEnvironment($app)
 | 
					    protected function defineEnvironment($app)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $app['config']->set('media-library.middleware', ['web']);
 | 
					        $app['config']->set('medialibrary-helper.middleware', ['web']);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue