mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Reformatted and checked everything. [skip ci]
This commit is contained in:
@@ -3,14 +3,29 @@
|
||||
|
||||
namespace Firefly\Storage\Component;
|
||||
|
||||
|
||||
/**
|
||||
* Interface ComponentRepositoryInterface
|
||||
*
|
||||
* @package Firefly\Storage\Component
|
||||
*/
|
||||
interface ComponentRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function count();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get();
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function store($data);
|
||||
|
||||
}
|
@@ -3,32 +3,56 @@
|
||||
|
||||
namespace Firefly\Storage\Component;
|
||||
|
||||
use Firefly\Exception\FireflyException;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
/**
|
||||
* Class EloquentComponentRepository
|
||||
*
|
||||
* @package Firefly\Storage\Component
|
||||
*/
|
||||
class EloquentComponentRepository implements ComponentRepositoryInterface
|
||||
{
|
||||
public $validator;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \Auth::user()->components()->count();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|void
|
||||
* @throws \Firefly\Exception\FireflyException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
die('no impl');
|
||||
throw new FireflyException('No implementation.');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
* @return \Budget|\Category|mixed
|
||||
* @throws \Firefly\Exception\FireflyException
|
||||
*/
|
||||
public function store($data)
|
||||
{
|
||||
if (!isset($data['class'])) {
|
||||
throw new \Firefly\Exception\FireflyException('No class type present.');
|
||||
throw new FireflyException('No class type present.');
|
||||
}
|
||||
switch ($data['class']) {
|
||||
default:
|
||||
case 'Budget':
|
||||
$component = new \Budget;
|
||||
break;
|
||||
@@ -41,9 +65,9 @@ class EloquentComponentRepository implements ComponentRepositoryInterface
|
||||
$component->user()->associate(\Auth::user());
|
||||
try {
|
||||
$component->save();
|
||||
} catch (\Illuminate\Database\QueryException $e) {
|
||||
} catch (QueryException $e) {
|
||||
\Log::error('DB ERROR: ' . $e->getMessage());
|
||||
throw new \Firefly\Exception\FireflyException('Could not save component ' . $data['name'] . ' of type'
|
||||
throw new FireflyException('Could not save component ' . $data['name'] . ' of type'
|
||||
. $data['class']);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user