File: D:/HostingSpaces/SBogers93/fitale.nl/workbench/komma/kms/src/Komma/Kms/Images/ImageController.php
<?php
/**
* Short description for the file.
*
* @author Tim Van Samang <timvansamang@komma.pro>
* @copyright (c) 2012-2015, Komma Mediadesign
*/
namespace Komma\Kms\Images;
use Komma\Kms\Images\Models\Image;
class ImageController extends \BaseController
{
private $imageService;
public function __construct(ImageService $imageService)
{
$this->imageService = $imageService;
}
public function upload()
{
//Set subFolder
if(\Input::has('subFolder')) $this->imageService->setUp('subfolder', \Input::get('subFolder'));
//Set attributeKey
if(\Input::has('attribute_key')) $this->imageService->setUp('attribute_key',\Input::get('attribute_key'));
$uploadSizes = [];
//Get the uploadSizes
if(\Input::has('uploadSizes') && is_array(\Input::get('uploadSizes')))$uploadSizes = \Input::get('uploadSizes');
$dynamic = false;
//Get if is dynamic
if(\Input::has('dynamic'))$dynamic =(\Input::get('dynamic') == 'true'?true:false);
//upload the files to the server
if (!$result = $this->imageService->uploadImages([\Input::file('file')],$uploadSizes,$dynamic)) return null;
//Save image to database
$image = $this->imageService->saveImageToDatabase($result[0]);
return $image->toJson();
}
}