Code clean up.

This commit is contained in:
James Cole
2017-11-15 10:52:29 +01:00
parent aee17221eb
commit 649dca77f5
305 changed files with 1200 additions and 1600 deletions

View File

@@ -36,7 +36,6 @@ use Illuminate\Database\Query\JoinClause;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Watson\Validating\ValidatingTrait;
/**
* Class Account
*
@@ -112,7 +111,6 @@ class Account extends Model
$account = self::create($fields);
return $account;
}
/**
@@ -122,7 +120,6 @@ class Account extends Model
*/
public static function routeBinder(Account $value)
{
if (auth()->check()) {
if (intval($value->user_id) === auth()->user()->id) {
return $value;
@@ -211,7 +208,6 @@ class Account extends Model
*/
public function getNameAttribute($value): string
{
if ($this->encrypted) {
return Crypt::decrypt($value);
}
@@ -321,9 +317,10 @@ class Account extends Model
{
$joinName = str_replace('.', '_', $name);
$query->leftJoin(
'account_meta as ' . $joinName, function (JoinClause $join) use ($joinName, $name) {
$join->on($joinName . '.account_id', '=', 'accounts.id')->where($joinName . '.name', '=', $name);
}
'account_meta as ' . $joinName,
function (JoinClause $join) use ($joinName, $name) {
$join->on($joinName . '.account_id', '=', 'accounts.id')->where($joinName . '.name', '=', $name);
}
);
$query->where($joinName . '.data', json_encode($value));
}

View File

@@ -75,5 +75,4 @@ class AccountMeta extends Model
{
$this->attributes['data'] = json_encode($value);
}
}

View File

@@ -62,7 +62,6 @@ class Attachment extends Model
public static function routeBinder(Attachment $value)
{
if (auth()->check()) {
if (intval($value->user_id) === auth()->user()->id) {
return $value;
}
@@ -209,5 +208,4 @@ class Attachment extends Model
{
return $this->belongsTo('FireflyIII\User');
}
}

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

View File

@@ -38,7 +38,6 @@ use Watson\Validating\ValidatingTrait;
*/
class Bill extends Model
{
use SoftDeletes, ValidatingTrait;
/**
* The attributes that should be casted to native types.
@@ -85,7 +84,6 @@ class Bill extends Model
*/
public function getMatchAttribute($value)
{
if (intval($this->match_encrypted) === 1) {
return Crypt::decrypt($value);
}
@@ -100,7 +98,6 @@ class Bill extends Model
*/
public function getNameAttribute($value)
{
if (intval($this->name_encrypted) === 1) {
return Crypt::decrypt($value);
}
@@ -159,6 +156,4 @@ class Bill extends Model
{
return $this->belongsTo('FireflyIII\User');
}
}

View File

@@ -37,7 +37,6 @@ use Watson\Validating\ValidatingTrait;
*/
class Budget extends Model
{
use SoftDeletes, ValidatingTrait;
/**
@@ -85,7 +84,6 @@ class Budget extends Model
$budget = self::create($fields);
return $budget;
}
/**
@@ -119,7 +117,6 @@ class Budget extends Model
*/
public function getNameAttribute($value)
{
if ($this->encrypted) {
return Crypt::decrypt($value);
}
@@ -160,6 +157,4 @@ class Budget extends Model
{
return $this->belongsTo('FireflyIII\User');
}
}

View File

@@ -93,5 +93,4 @@ class BudgetLimit extends Model
{
$this->attributes['amount'] = strval(round($value, 12));
}
}

View File

@@ -83,7 +83,6 @@ class Category extends Model
$category = self::create($fields);
return $category;
}
/**
@@ -109,7 +108,6 @@ class Category extends Model
*/
public function getNameAttribute($value)
{
if ($this->encrypted) {
return Crypt::decrypt($value);
}
@@ -151,5 +149,4 @@ class Category extends Model
{
return $this->belongsTo('FireflyIII\User');
}
}

View File

@@ -64,6 +64,4 @@ class Configuration extends Model
{
$this->attributes['data'] = json_encode($value);
}
}

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -62,5 +61,4 @@ class CurrencyExchangeRate extends Model
{
return $this->belongsTo(User::class);
}
}

View File

@@ -98,7 +98,6 @@ class ImportJob extends Model
$status['done'] += $count;
$this->extended_status = $status;
$this->save();
}
/**
@@ -110,7 +109,6 @@ class ImportJob extends Model
$status['steps'] += $count;
$this->extended_status = $status;
$this->save();
}
/**

View File

@@ -90,5 +90,4 @@ class LimitRepetition extends Model
{
$this->attributes['amount'] = strval(round($value, 2));
}
}

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -72,5 +71,4 @@ class LinkType extends Model
{
return $this->hasMany(TransactionJournalLink::class);
}
}

View File

@@ -65,5 +65,4 @@ class Note extends Model
{
return $this->morphTo();
}
}

View File

@@ -115,7 +115,6 @@ class PiggyBank extends Model
*/
public function getNameAttribute($value)
{
if ($this->encrypted) {
return Crypt::decrypt($value);
}
@@ -156,7 +155,6 @@ class PiggyBank extends Model
*/
public function leftOnAccount(Carbon $date): string
{
$balance = Steam::balanceIgnoreVirtual($this->account, $date);
/** @var PiggyBank $p */
foreach ($this->account->piggyBanks as $piggyBank) {
@@ -166,7 +164,6 @@ class PiggyBank extends Model
}
return $balance;
}
/**

View File

@@ -72,5 +72,4 @@ class PiggyBankEvent extends Model
{
return $this->belongsTo('FireflyIII\Models\TransactionJournal');
}
}

View File

@@ -89,7 +89,6 @@ class PiggyBankRepetition extends Model
)
->where(
function (EloquentBuilder $q) use ($date) {
$q->where('targetdate', '>=', $date->format('Y-m-d 00:00:00'));
$q->orWhereNull('targetdate');
}
@@ -103,5 +102,4 @@ class PiggyBankRepetition extends Model
{
$this->attributes['currentamount'] = strval(round($value, 12));
}
}

View File

@@ -96,5 +96,4 @@ class Preference extends Model
{
return $this->belongsTo('FireflyIII\User');
}
}

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
@@ -53,5 +52,4 @@ class Role extends Model
{
return $this->belongsToMany('FireflyIII\User');
}
}

View File

@@ -97,5 +97,4 @@ class Rule extends Model
{
return $this->belongsTo('FireflyIII\User');
}
}

View File

@@ -89,7 +89,6 @@ class Tag extends Model
$tag = self::create($fields);
return $tag;
}
/**
@@ -204,6 +203,4 @@ class Tag extends Model
{
return $this->belongsTo('FireflyIII\User');
}
}

View File

@@ -333,7 +333,6 @@ class TransactionJournal extends Model
$query->orderBy('transaction_journals.date', 'DESC');
$query->orderBy('transaction_journals.order', 'ASC');
$query->orderBy('transaction_journals.id', 'DESC');
}
/**
@@ -343,7 +342,6 @@ class TransactionJournal extends Model
*/
public function scopeTransactionTypes(EloquentBuilder $query, array $types)
{
if (!self::isJoined($query, 'transaction_types')) {
$query->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id');
}
@@ -453,5 +451,4 @@ class TransactionJournal extends Model
{
return $this->belongsTo('FireflyIII\User');
}
}

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Crypt;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -111,6 +110,4 @@ class TransactionJournalLink extends Model
{
return $this->belongsTo(TransactionJournal::class, 'source_id');
}
}

View File

@@ -34,7 +34,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
*/
class TransactionJournalMeta extends Model
{
use SoftDeletes;
/**
* The attributes that should be casted to native types.

View File

@@ -68,7 +68,6 @@ class TransactionType extends Model
return $transactionType;
}
throw new NotFoundHttpException;
}