mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
First attempt, trying to build an import stuff routine.
This commit is contained in:
39
app/lib/Firefly/Storage/Import/EloquentImportRepository.php
Normal file
39
app/lib/Firefly/Storage/Import/EloquentImportRepository.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Firefly\Storage\Import;
|
||||
|
||||
|
||||
class EloquentImportRepository implements ImportRepositoryInterface
|
||||
{
|
||||
|
||||
public function findImportComponentMap(\Importmap $map, $oldComponentId)
|
||||
{
|
||||
$entry = \Importentry::where('importmap_id', $map->id)
|
||||
->whereIn('class', ['Budget', 'Category', 'Account', 'Component'])
|
||||
->where('old', intval($oldComponentId))->first();
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
public function findImportEntry(\Importmap $map, $class, $oldID)
|
||||
{
|
||||
|
||||
return \Importentry::where('importmap_id', $map->id)->where('class', $class)->where('old', $oldID)->first();
|
||||
}
|
||||
|
||||
public function findImportMap($id)
|
||||
{
|
||||
return \Importmap::find($id);
|
||||
}
|
||||
|
||||
public function store(\Importmap $map, $class, $oldID, $newID)
|
||||
{
|
||||
$entry = new \Importentry;
|
||||
$entry->importmap()->associate($map);
|
||||
$entry->class = $class;
|
||||
$entry->old = intval($oldID);
|
||||
$entry->new = intval($newID);
|
||||
$entry->save();
|
||||
}
|
||||
|
||||
}
|
27
app/lib/Firefly/Storage/Import/ImportRepositoryInterface.php
Normal file
27
app/lib/Firefly/Storage/Import/ImportRepositoryInterface.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Firefly\Storage\Import;
|
||||
|
||||
/**
|
||||
* Interface ImportRepositoryInterface
|
||||
* @package Firefly\Storage\Import
|
||||
*/
|
||||
interface ImportRepositoryInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param \Importmap $map
|
||||
* @param $class
|
||||
* @param $oldID
|
||||
* @param $newID
|
||||
* @return mixed
|
||||
*/
|
||||
public function store(\Importmap $map, $class, $oldID, $newID);
|
||||
|
||||
public function findImportMap($id);
|
||||
|
||||
public function findImportEntry(\Importmap $map, $class, $oldID);
|
||||
|
||||
public function findImportComponentMap(\Importmap $map, $oldComponentId);
|
||||
}
|
Reference in New Issue
Block a user