mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 20:16:22 +00:00
All kinds of new stuff: finished most of the importing routines, extended the database (single table inheritance) and expanded some other stuff.
This commit is contained in:
@@ -20,18 +20,26 @@ class EloquentComponentRepository implements ComponentRepositoryInterface
|
||||
|
||||
public function store($data)
|
||||
{
|
||||
if (!isset($data['component_type'])) {
|
||||
throw new \Firefly\Exception\FireflyException('No component type present.');
|
||||
if (!isset($data['class'])) {
|
||||
throw new \Firefly\Exception\FireflyException('No class type present.');
|
||||
}
|
||||
switch ($data['class']) {
|
||||
case 'Budget':
|
||||
$component = new \Budget;
|
||||
break;
|
||||
case 'Category':
|
||||
$component = new \Category;
|
||||
break;
|
||||
|
||||
}
|
||||
$component = new \Component;
|
||||
$component->componentType()->associate($data['component_type']);
|
||||
$component->name = $data['name'];
|
||||
$component->user()->associate(\Auth::user());
|
||||
try {
|
||||
$component->save();
|
||||
} catch (\Illuminate\Database\QueryException $e) {
|
||||
\Log::error('DB ERROR: ' . $e->getMessage());
|
||||
throw new \Firefly\Exception\FireflyException('Could not save component ' . $data['name']);
|
||||
throw new \Firefly\Exception\FireflyException('Could not save component ' . $data['name'] . ' of type'
|
||||
. $data['class']);
|
||||
}
|
||||
|
||||
return $component;
|
||||
|
Reference in New Issue
Block a user