Skip to content
This repository has been archived by the owner on Jun 11, 2019. It is now read-only.

Commit

Permalink
From manager
Browse files Browse the repository at this point in the history
  • Loading branch information
joselfonseca committed Sep 23, 2015
1 parent 13a107d commit 46224cd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
31 changes: 31 additions & 0 deletions migrations/2015_09_16_083228_UpdateImageManagerFilesTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class UpdateImageManagerFilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('image_manager_files', function($table){
$table->boolean('from_manager')->default(1);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('image_manager_files', function($table){
$table->dropColumn('from_manager');
});
}
}
2 changes: 1 addition & 1 deletion src/Models/ImageManagerFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 4 additions & 3 deletions src/Repositories/ImageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit 46224cd

Please sign in to comment.