Created
July 17, 2018 15:14
-
-
Save diego3g/66416eb5556529067872d847157e9f23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async store ({ params, request }) { | |
const property = await Property.findOrFail(params.id) | |
const images = request.file('image', { | |
types: ['image'], | |
size: '2mb' | |
}) | |
await images.moveAll(Helpers.tmpPath('uploads'), file => ({ | |
name: `${Date.now()}-${file.clientName}` | |
})) | |
if (!images.movedAll()) { | |
return images.errors() | |
} | |
await Promise.all( | |
images | |
.movedList() | |
.map(image => property.images().create({ path: image.fileName })) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment