General cleanup.

This commit is contained in:
James Cole
2015-05-03 12:58:55 +02:00
parent bb84f7a434
commit 4a51176193
34 changed files with 147 additions and 62 deletions

View File

@@ -51,7 +51,7 @@ class Account extends Model
$account = Account::create($fields);
if (is_null($account->id)) {
// could not create account:
App::abort(500, 'Could not create new account with data: ' . json_encode($fields).' because ' . json_encode($account->getErrors()));
App::abort(500, 'Could not create new account with data: ' . json_encode($fields) . ' because ' . json_encode($account->getErrors()));
}

View File

@@ -1,9 +1,10 @@
<?php namespace FireflyIII\Models;
use App;
use Crypt;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App;
/**
* Class Category
*

View File

@@ -14,7 +14,7 @@ class PiggyBank extends Model
use SoftDeletes;
protected $fillable
= ['name', 'account_id','order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];
= ['name', 'account_id', 'order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo

View File

@@ -78,6 +78,11 @@ class Reminder extends Model
return $query->where('reminders.startdate', '=', $start->format('Y-m-d 00:00:00'))->where('reminders.enddate', '=', $end->format('Y-m-d 00:00:00'));
}
/**
* @param EloquentBuilder $query
*
* @return $this
*/
public function scopeToday(EloquentBuilder $query)
{
$today = new Carbon;

View File

@@ -52,9 +52,9 @@ class Tag extends Model
}
}
// create it!
$fields['tagMode'] = 'nothing';
$fields['tagMode'] = 'nothing';
$fields['description'] = isset($fields['description']) && !is_null($fields['description']) ? $fields['description'] : '';
$tag = Tag::create($fields);
$tag = Tag::create($fields);
if (is_null($tag->id)) {
// could not create account:
App::abort(500, 'Could not create new tag with data: ' . json_encode($fields) . ' because ' . json_encode($tag->getErrors()));

View File

@@ -66,8 +66,13 @@ class TransactionJournal extends Model
return floatval($t->amount);
}
}
return 0;
}
/**
* @return Account|mixed
*/
public function getAssetAccountAttribute()
{
$positive = true; // the asset account is in the transaction with the positive amount.