/**
  * @param RuleGroupRepositoryInterface $repository
  *
  * @return View
  */
 public function index(RuleGroupRepositoryInterface $repository)
 {
     $this->createDefaultRuleGroup();
     $this->createDefaultRule();
     $ruleGroups = $repository->getRuleGroupsWithRules(auth()->user());
     return view('rules.index', compact('ruleGroups'));
 }
 /**
  * @param RuleGroupFormRequest         $request
  * @param RuleGroupRepositoryInterface $repository
  * @param RuleGroup                    $ruleGroup
  *
  * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function update(RuleGroupFormRequest $request, RuleGroupRepositoryInterface $repository, RuleGroup $ruleGroup)
 {
     $data = ['title' => $request->input('title'), 'description' => $request->input('description'), 'active' => intval($request->input('active')) == 1];
     $repository->update($ruleGroup, $data);
     Session::flash('success', trans('firefly.updated_rule_group', ['title' => $ruleGroup->title]));
     Preferences::mark();
     if (intval(Input::get('return_to_edit')) === 1) {
         // set value so edit routine will not overwrite URL:
         Session::put('rules.rule-group.edit.fromUpdate', true);
         return redirect(route('rules.rule-group.edit', [$ruleGroup->id]))->withInput(['return_to_edit' => 1]);
     }
     // redirect to previous URL.
     return redirect(Session::get('rules.rule-group.edit.url'));
 }