Skip to content

Instantly share code, notes, and snippets.

@ryanmr
Created August 23, 2015 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanmr/3d9d33a15f8e8adb8b3f to your computer and use it in GitHub Desktop.
Save ryanmr/3d9d33a15f8e8adb8b3f to your computer and use it in GitHub Desktop.
<?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