Group management code.

This commit is contained in:
James Cole
2020-06-20 10:10:55 +02:00
parent b54ef9f5e5
commit 5b29e78c4b
25 changed files with 737 additions and 14 deletions

View File

@@ -6,14 +6,13 @@ namespace FireflyIII\Repositories\ObjectGroup;
use DB;
use FireflyIII\Models\ObjectGroup;
use Illuminate\Support\Collection;
use Log;
/**
* Class ObjectGroupRepository
*/
class ObjectGroupRepository implements ObjectGroupRepositoryInterface
{
/**
* @inheritDoc
*/
@@ -73,4 +72,37 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface
$group->save();
}
}
/**
* @inheritDoc
*/
public function setOrder(ObjectGroup $objectGroup, int $order): ObjectGroup
{
$order = 0 === $order ? 1 : $order;
$objectGroup->order = $order;
$objectGroup->save();
Log::debug(sprintf('Objectgroup #%d order is now %d', $objectGroup->id, $order));
return $objectGroup;
}
/**
* @inheritDoc
*/
public function update(ObjectGroup $objectGroup, array $data): ObjectGroup
{
$objectGroup->title = $data['title'];
$objectGroup->save();
return $objectGroup;
}
/**
* @inheritDoc
*/
public function destroy(ObjectGroup $objectGroup): void
{
$objectGroup->delete();
}
}