Created
September 30, 2016 09:24
-
-
Save freshface/045d803f0b55680ca97ffa92f78a1f08 to your computer and use it in GitHub Desktop.
CreateContentBlockHandler
This file contains hidden or 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
public function handle(CreateContentBlock $createContentBlock) | |
{ | |
$createContentBlock->contentBlock = ContentBlock::create( | |
$this->contentBlockRepository->getNextIdForLanguage($createContentBlock->language), | |
$createContentBlock->userId, | |
$this->getNewExtraId(), | |
$createContentBlock->language, | |
$createContentBlock->title, | |
$createContentBlock->text, | |
!$createContentBlock->isVisible, | |
$createContentBlock->template, | |
$createContentBlock->image | |
); | |
$image = $createContentBlock->contentBlock->getImage(); | |
// Generate a unique name for the file before saving it | |
$imageName = md5(uniqid()) . '.' .$image->guessExtension(); | |
$createContentBlock->contentBlock->setImage($imageName); | |
// Move the file to the directory where brochures are stored | |
$image->move( | |
'test', | |
$imageName | |
); | |
$this->contentBlockRepository->add($createContentBlock->contentBlock); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment