More code for the new CSV import

This commit is contained in:
James Cole
2016-06-27 15:15:46 +02:00
parent 93a54780ab
commit 18d2741814
9 changed files with 499 additions and 34 deletions

View File

@@ -12,7 +12,9 @@ declare(strict_types = 1);
namespace FireflyIII\Models;
use Auth;
use Crypt;
use Illuminate\Database\Eloquent\Model;
use Storage;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -67,15 +69,6 @@ class ImportJob extends Model
$this->save();
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('FireflyIII\User');
}
/**
* @param $value
*
@@ -86,8 +79,8 @@ class ImportJob extends Model
if (strlen($value) == 0) {
return [];
}
return json_decode($value);
return json_decode($value, true);
}
/**
@@ -97,4 +90,25 @@ class ImportJob extends Model
{
$this->attributes['configuration'] = json_encode($value);
}
/**
* @return string
*/
public function uploadFileContents(): string
{
$fileName = $this->key . '.upload';
$disk = Storage::disk('upload');
$encryptedContent = $disk->get($fileName);
$content = Crypt::decrypt($encryptedContent);
return $content;
}
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('FireflyIII\User');
}
}