diff --git a/migrations/2015_09_16_083228_UpdateImageManagerFilesTable.php b/migrations/2015_09_16_083228_UpdateImageManagerFilesTable.php new file mode 100644 index 0000000..652cd46 --- /dev/null +++ b/migrations/2015_09_16_083228_UpdateImageManagerFilesTable.php @@ -0,0 +1,31 @@ +boolean('from_manager')->default(1); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('image_manager_files', function($table){ + $table->dropColumn('from_manager'); + }); + } +} diff --git a/src/Models/ImageManagerFiles.php b/src/Models/ImageManagerFiles.php index 338e26d..dac6ddd 100644 --- a/src/Models/ImageManagerFiles.php +++ b/src/Models/ImageManagerFiles.php @@ -15,7 +15,7 @@ class ImageManagerFiles extends Model implements ImageDbStorageInterface { protected $table = 'image_manager_files'; - protected $fillable = ['name', 'originalName', 'type', 'path', 'size']; + protected $fillable = ['name', 'originalName', 'type', 'path', 'size', 'from_manager']; use EventGenerator; diff --git a/src/Repositories/ImageRepository.php b/src/Repositories/ImageRepository.php index d9721e1..7469e99 100644 --- a/src/Repositories/ImageRepository.php +++ b/src/Repositories/ImageRepository.php @@ -52,7 +52,7 @@ public function __construct(ImageDbStorageInterface $model) { * @return mixed * @throws AlocateFileException */ - public function uploadFile($command) { + public function uploadFile($command, $fromManager = 1) { $filename = $command->file->getClientOriginalName(); $ext = pathinfo($filename, PATHINFO_EXTENSION); $finalFile = md5(md5($filename . date('U'))) . '.' . $ext; @@ -65,7 +65,8 @@ public function uploadFile($command) { 'originalName' => $filename, 'type' => $upload_success->getMimeType(), 'path' => $finalFile, - 'size' => $upload_success->getSize() + 'size' => $upload_success->getSize(), + 'from_manager' => $fromManager ]; $this->raise(new FileWasSavedToDisc($file)); return $this->model->saveFileToDb($file); @@ -91,7 +92,7 @@ public function renderImage($command) { * @return mixed */ public function getFiles() { - return $this->model->orderBy('created_at', 'desc')->paginate(12); + return $this->model->orderBy('created_at', 'desc')->where('from_manager', 1)->paginate(12); } /**