diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 147ca6040a..34dac7bf27 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -1,6 +1,8 @@ auth->login($this->registrar->create($data)); // get the email address - $email = $this->auth->user()->email; + if ($this->auth->user() instanceof User) { + $email = $this->auth->user()->email; - // send email. - Mail::send( - 'emails.registered', [], function(Message $message) use ($email) { - $message->to($email, $email)->subject('Welcome to Firefly III!'); + // send email. + Mail::send( + 'emails.registered', [], function (Message $message) use ($email) { + $message->to($email, $email)->subject('Welcome to Firefly III!'); + } + ); + + // set flash message + Session::flash('success', 'You have registered successfully!'); + Session::flash('gaEventCategory', 'user'); + Session::flash('gaEventAction', 'new-registration'); + + + return redirect($this->redirectPath()); } - ); + App::abort(500, 'Not a user!'); - // set flash message - Session::flash('success', 'You have registered successfully!'); - Session::flash('gaEventCategory', 'user'); - Session::flash('gaEventAction', 'new-registration'); - - - return redirect($this->redirectPath()); + return false; } } diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 2ebef96f41..b15f83427c 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -118,7 +118,7 @@ class TransactionController extends Controller */ public function edit(AccountRepositoryInterface $repository, TransactionJournal $journal) { - $what = strtolower($journal->transactiontype->type); + $what = strtolower($journal->transactionType->type); $accounts = ExpandedForm::makeSelectList($repository->getAccounts(['Default account', 'Asset account'])); $budgets = ExpandedForm::makeSelectList(Auth::user()->budgets()->get()); $budgets[0] = trans('form.noBudget'); @@ -153,7 +153,7 @@ class TransactionController extends Controller $preFilled['piggy_bank_id'] = $journal->piggyBankEvents()->orderBy('date', 'DESC')->first()->piggy_bank_id; } - $preFilled['amount'] = $journal->actualAmount; + $preFilled['amount'] = $journal->actual_amount; $preFilled['account_id'] = $journal->assetAccount->id; $preFilled['expense_account'] = $transactions[0]->account->name; $preFilled['revenue_account'] = $transactions[1]->account->name; @@ -254,7 +254,7 @@ class TransactionController extends Controller $t->after = $t->before + $t->amount; } ); - $subTitle = trans('firefly.' . $journal->transactiontype->type) . ' "' . e($journal->description) . '"'; + $subTitle = trans('firefly.' . $journal->transactionType->type) . ' "' . e($journal->description) . '"'; return view('transactions.show', compact('journal', 'subTitle')); } diff --git a/app/Http/Middleware/Reminders.php b/app/Http/Middleware/Reminders.php index 869b1f170a..9814e448d0 100644 --- a/app/Http/Middleware/Reminders.php +++ b/app/Http/Middleware/Reminders.php @@ -7,6 +7,7 @@ use Carbon\Carbon; use Closure; use FireflyIII\Models\PiggyBank; use FireflyIII\Models\Reminder; +use FireflyIII\User; use Illuminate\Contracts\Auth\Guard; use Illuminate\Http\Request; use View; @@ -48,30 +49,33 @@ class Reminders { if ($this->auth->check() && !$request->isXmlHttpRequest()) { // do reminders stuff. - $piggyBanks = $this->auth->user()->piggyBanks()->where('remind_me', 1)->get(); - /** @var \FireflyIII\Helpers\Reminders\ReminderHelperInterface $helper */ - $helper = App::make('FireflyIII\Helpers\Reminders\ReminderHelperInterface'); + $reminders = []; + if ($this->auth->user() instanceof User) { + $piggyBanks = $this->auth->user()->piggyBanks()->where('remind_me', 1)->get(); + /** @var \FireflyIII\Helpers\Reminders\ReminderHelperInterface $helper */ + $helper = App::make('FireflyIII\Helpers\Reminders\ReminderHelperInterface'); - /** @var PiggyBank $piggyBank */ - foreach ($piggyBanks as $piggyBank) { - $helper->createReminders($piggyBank, new Carbon); - } - // delete invalid reminders - // this is a construction SQLITE cannot handle :( - if (env('DB_CONNECTION') != 'sqlite') { - Reminder::whereUserId($this->auth->user()->id) - ->leftJoin('piggy_banks', 'piggy_banks.id', '=', 'remindersable_id') - ->whereNull('piggy_banks.id') - ->delete(); - } - - // get and list active reminders: - $reminders = $this->auth->user()->reminders()->today()->get(); - $reminders->each( - function(Reminder $reminder) use ($helper) { - $reminder->description = $helper->getReminderText($reminder); + /** @var PiggyBank $piggyBank */ + foreach ($piggyBanks as $piggyBank) { + $helper->createReminders($piggyBank, new Carbon); } - ); + // delete invalid reminders + // this is a construction SQLITE cannot handle :( + if (env('DB_CONNECTION') != 'sqlite') { + Reminder::whereUserId($this->auth->user()->id) + ->leftJoin('piggy_banks', 'piggy_banks.id', '=', 'remindersable_id') + ->whereNull('piggy_banks.id') + ->delete(); + } + + // get and list active reminders: + $reminders = $this->auth->user()->reminders()->today()->get(); + $reminders->each( + function (Reminder $reminder) use ($helper) { + $reminder->description = $helper->getReminderText($reminder); + } + ); + } View::share('reminders', $reminders); } diff --git a/app/Models/Account.php b/app/Models/Account.php index a47a7f75d7..4f0737450b 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -40,6 +40,11 @@ use Watson\Validating\ValidatingTrait; * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Account whereVirtualBalanceEncrypted($value) * @method static \FireflyIII\Models\Account accountTypeIn($types) * @method static \FireflyIII\Models\Account hasMetaValue($name, $value) + * + * @property boolean joinedAccountTypes + * @property mixed startBalance + * @property mixed endBalance + * @property mixed lastActivityDate */ class Account extends Model { diff --git a/app/Models/Bill.php b/app/Models/Bill.php index d7517da9c1..125b25f480 100644 --- a/app/Models/Bill.php +++ b/app/Models/Bill.php @@ -44,6 +44,9 @@ use Illuminate\Database\Eloquent\Model; * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereSkip($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereNameEncrypted($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Bill whereMatchEncrypted($value) + * + * @property mixed nextExpectedMatch + * @property mixed lastFoundMatch */ class Bill extends Model { diff --git a/app/Models/Category.php b/app/Models/Category.php index b1cd0f5d71..05c35149fa 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -24,6 +24,9 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereName($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereUserId($value) * @method static \Illuminate\Database\Query\Builder|\FireflyIII\Models\Category whereEncrypted($value) + * + * @property mixed spent + * @property mixed lastActivity */ class Category extends Model { diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index 212682c5e9..25f45e70c9 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -61,6 +61,11 @@ use Watson\Validating\ValidatingTrait; * @method static \FireflyIII\Models\TransactionJournal transactionTypes($types) * @method static \FireflyIII\Models\TransactionJournal withRelevantData() * @property-read mixed $expense_account + * @property string account_encrypted + * @property bool joinedTransactions + * @property bool joinedTransactionTypes + * @property mixed account_id + * @property mixed name */ class TransactionJournal extends Model { @@ -152,7 +157,7 @@ class TransactionJournal extends Model // loop other deposits, remove from our amount. $others = $advancePayment->transactionJournals()->transactionTypes(['Deposit'])->get(); foreach ($others as $other) { - $amount = bcsub($amount, $other->actualAmount); + $amount = bcsub($amount, $other->actual_amount); } return $amount; @@ -173,7 +178,7 @@ class TransactionJournal extends Model if ($this->transactionType->type == 'Withdrawal') { $transfer = $balancingAct->transactionJournals()->transactionTypes(['Transfer'])->first(); if ($transfer) { - $amount = bcsub($amount, $transfer->actualAmount); + $amount = bcsub($amount, $transfer->actual_amount); return $amount; }