Code rearrangement.

This commit is contained in:
James Cole
2016-01-19 13:59:54 +01:00
parent 9360eb6a70
commit f3fff6f1c5
18 changed files with 805 additions and 822 deletions

View File

@@ -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

View File

@@ -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
*/