Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbaljet committed Oct 5, 2020
1 parent f4fa043 commit 7bcf2a3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ $ghostscript = new Ghostscript('gs-binary');

## Convert Base64 input data to files

Add the `ConvertsBase64ToFiles` trait and `base64ImageKeys` method to your form request.
Add the `ConvertsBase64ToFiles` trait and `base64FileKeys` method to your form request.

```php
use Illuminate\Foundation\Http\FormRequest;
Expand All @@ -276,7 +276,7 @@ class ImageRequest extends FormRequest
{
use ConvertsBase64ToFiles;

protected function base64ImageKeys(): array
protected function base64FileKeys(): array
{
return [
'jpg_image' => 'Logo.jpg',
Expand Down
9 changes: 2 additions & 7 deletions src/Request/ConvertsBase64ToFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@

trait ConvertsBase64ToFiles
{
/**
* Specify all input keys that should be converted.
*
* @return array
*/
protected function base64ImageKeys(): array
protected function base64FileKeys(): array
{
return [];
}
Expand All @@ -27,7 +22,7 @@ protected function base64ImageKeys(): array
*/
protected function prepareForValidation()
{
Collection::make($this->base64ImageKeys())->each(function ($filename, $key) {
Collection::make($this->base64FileKeys())->each(function ($filename, $key) {
rescue(function () use ($key, $filename) {
$base64Contents = $this->input($key);

Expand Down
4 changes: 2 additions & 2 deletions tests/Request/ConvertsBase64ToFilesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ImageRequest extends FormRequest
{
use ConvertsBase64ToFiles;

protected function base64ImageKeys(): array
protected function base64FileKeys(): array
{
return [
'png_image' => 'Logo1.png',
Expand All @@ -32,7 +32,7 @@ class ZipRequest extends FormRequest
{
use ConvertsBase64ToFiles;

protected function base64ImageKeys(): array
protected function base64FileKeys(): array
{
return [
'zip' => 'Logo.zip',
Expand Down

0 comments on commit 7bcf2a3

Please sign in to comment.