From ea4f7f79cedbb84fe56b94abb6a2a0c7ce7591ae Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 27 Mar 2015 18:17:15 +0100 Subject: [PATCH] Removed more references. --- app/Http/routes.php | 14 -------------- app/Models/PiggyBank.php | 38 +++----------------------------------- 2 files changed, 3 insertions(+), 49 deletions(-) diff --git a/app/Http/routes.php b/app/Http/routes.php index 4f720a3a4e..89e5e5bd1b 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -28,20 +28,6 @@ Route::bind( } ); -Route::bind( - 'repeatedExpense', function ($value, $route) { - if (Auth::check()) { - return PiggyBank:: - where('piggy_banks.id', $value) - ->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id') - ->where('accounts.user_id', Auth::user()->id) - ->where('repeats', 1)->first(['piggy_banks.*']); - } - - return null; -} -); - Route::bind( 'tjSecond', function ($value, $route) { if (Auth::check()) { diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php index 2bb790dd1b..c674576662 100644 --- a/app/Models/PiggyBank.php +++ b/app/Models/PiggyBank.php @@ -4,7 +4,7 @@ use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; - +use App; /** * Class PiggyBank * @@ -36,46 +36,14 @@ class PiggyBank extends Model if (!is_null($this->currentRep)) { return $this->currentRep; } + // repeating piggy banks are no longer supported. if (intval($this->repeats) === 0) { $rep = $this->piggyBankRepetitions()->first(['piggy_bank_repetitions.*']); $this->currentRep = $rep; return $rep; } else { - $query = $this->piggyBankRepetitions()->where( - function (EloquentBuilder $q) { - - $q->where( - function (EloquentBuilder $q) { - - $q->where( - function (EloquentBuilder $q) { - $today = new Carbon; - $q->whereNull('startdate'); - $q->orWhere('startdate', '<=', $today->format('Y-m-d 00:00:00')); - } - )->where( - function (EloquentBuilder $q) { - $today = new Carbon; - $q->whereNull('targetdate'); - $q->orWhere('targetdate', '>=', $today->format('Y-m-d 00:00:00')); - } - ); - } - )->orWhere( - function (EloquentBuilder $q) { - $today = new Carbon; - $q->where('startdate', '>=', $today->format('Y-m-d 00:00:00')); - $q->where('targetdate', '>=', $today->format('Y-m-d 00:00:00')); - } - ); - - } - )->orderBy('startdate', 'ASC'); - $result = $query->first(['piggy_bank_repetitions.*']); - $this->currentRep = $result; - - return $result; + App::abort(500); }