From 5ac88623ed9135887c655705128369de6d2b147b Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 13 Jan 2016 16:05:39 +0100 Subject: [PATCH] Prep stuff for routes and actions. --- app/Http/Controllers/RuleController.php | 9 +++++++++ app/Models/Rule.php | 18 +++++++++++++++++- config/firefly.php | 2 ++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/RuleController.php b/app/Http/Controllers/RuleController.php index 3c7ce3f31e..433c637332 100644 --- a/app/Http/Controllers/RuleController.php +++ b/app/Http/Controllers/RuleController.php @@ -11,6 +11,7 @@ namespace FireflyIII\Http\Controllers; use Auth; use FireflyIII\Http\Requests; +use FireflyIII\Models\Rule; use View; /** @@ -40,4 +41,12 @@ class RuleController extends Controller return view('rules.index', compact('ruleGroups')); } + + /** + * @param Rule $rule + */ + public function upRule(Rule $rule) + { + + } } diff --git a/app/Models/Rule.php b/app/Models/Rule.php index 7919401c5e..ca438e3224 100644 --- a/app/Models/Rule.php +++ b/app/Models/Rule.php @@ -9,8 +9,9 @@ namespace FireflyIII\Models; -use Illuminate\Database\Eloquent\Builder; +use Auth; use Illuminate\Database\Eloquent\Model; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class Rule @@ -66,4 +67,19 @@ class Rule extends Model return $this->hasMany('FireflyIII\Models\RuleTrigger'); } + /** + * @param Rule $value + * + * @return Rule + */ + public static function routeBinder(Rule $value) + { + if (Auth::check()) { + if ($value->user_id == Auth::user()->id) { + return $value; + } + } + throw new NotFoundHttpException; + } + } diff --git a/config/firefly.php b/config/firefly.php index 8a01676e8a..ddef1a0805 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -158,6 +158,8 @@ return [ 'piggyBank' => 'FireflyIII\Models\PiggyBank', 'tj' => 'FireflyIII\Models\TransactionJournal', 'tag' => 'FireflyIII\Models\Tag', + 'rule' => 'FireflyIII\Models\Rule', + 'ruleGroup' => 'FireflyIII\Models\RuleGroup', // lists 'accountList' => 'FireflyIII\Support\Binder\AccountList', 'budgetList' => 'FireflyIII\Support\Binder\BudgetList',