Created
August 23, 2015 07:57
-
-
Save ryanmr/3d9d33a15f8e8adb8b3f 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
<?php | |
/** | |
* Handle a new uploaded art file! | |
* | |
* 1. Validate that the file is a proper image | |
* 2. The art is untitled coming up, so give it a fake name for now. | |
* 3. Save the uploaded art using Job/SaveUploadedArt. | |
* 4. Save the resized copies based on the original using Job/ResizeArt. | |
* 5. Return the art data. | |
* | |
* @return Response | |
*/ | |
public function upload(Request $request) { | |
$this->validate($request, [ | |
'file' => 'required|mimes:jpg,jpeg,png,gif' | |
]); | |
$file = $request->file('file'); | |
$art = new \App\AlbumArt(['name' => 'New Album Art']); | |
$art->save(); | |
$this->dispatch(new \App\Jobs\SaveUploadedArt($art, $file)); | |
$this->dispatch(new \App\Jobs\ResizeArt($art)); | |
return $art; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment