mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 22:21:42 +00:00
Code rearrangement.
This commit is contained in:
@@ -46,6 +46,13 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return Auth::user()->ruleGroups()->orderBy('order', 'ASC')->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
@@ -57,36 +64,6 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
return intval($entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return Auth::user()->ruleGroups()->orderBy('order', 'ASC')->get();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveUp(RuleGroup $ruleGroup)
|
||||
{
|
||||
$order = $ruleGroup->order;
|
||||
|
||||
// find the rule with order-1 and give it order+1
|
||||
$other = Auth::user()->ruleGroups()->where('order', ($order - 1))->first();
|
||||
if ($other) {
|
||||
$other->order = ($other->order + 1);
|
||||
$other->save();
|
||||
}
|
||||
|
||||
$ruleGroup->order = ($ruleGroup->order - 1);
|
||||
$ruleGroup->save();
|
||||
$this->resetRuleGroupOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
@@ -108,6 +85,26 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
$this->resetRuleGroupOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveUp(RuleGroup $ruleGroup)
|
||||
{
|
||||
$order = $ruleGroup->order;
|
||||
|
||||
// find the rule with order-1 and give it order+1
|
||||
$other = Auth::user()->ruleGroups()->where('order', ($order - 1))->first();
|
||||
if ($other) {
|
||||
$other->order = ($other->order + 1);
|
||||
$other->save();
|
||||
}
|
||||
|
||||
$ruleGroup->order = ($ruleGroup->order - 1);
|
||||
$ruleGroup->save();
|
||||
$this->resetRuleGroupOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
|
||||
@@ -21,6 +21,10 @@ interface RuleGroupRepositoryInterface
|
||||
*/
|
||||
public function destroy(RuleGroup $ruleGroup, RuleGroup $moveTo = null);
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function get();
|
||||
|
||||
/**
|
||||
* @return int
|
||||
@@ -28,9 +32,11 @@ interface RuleGroupRepositoryInterface
|
||||
public function getHighestOrderRuleGroup();
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function get();
|
||||
public function moveDown(RuleGroup $ruleGroup);
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
@@ -39,13 +45,6 @@ interface RuleGroupRepositoryInterface
|
||||
*/
|
||||
public function moveUp(RuleGroup $ruleGroup);
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function moveDown(RuleGroup $ruleGroup);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user