make sure all route binders use guard.

This commit is contained in:
James Cole
2018-02-07 11:15:36 +01:00
parent eacc1da157
commit 909dc212fb
27 changed files with 86 additions and 84 deletions

View File

@@ -118,11 +118,11 @@ class Account extends Model
*
* @return Account
*/
public static function routeBinder(string $value): Account
public static function routeBinder($guard, string $value): Account
{
if (auth()->check()) {
if ($guard->check()) {
$accountId = intval($value);
$account = auth()->user()->accounts()->find($accountId);
$account = $guard->user()->accounts()->find($accountId);
if (!is_null($account)) {
return $account;
}
@@ -290,6 +290,15 @@ class Account extends Model
return $journal->date;
}
/**
* @codeCoverageIgnore
* Get all of the notes.
*/
public function notes()
{
return $this->morphMany(Note::class, 'noteable');
}
/**
* @return HasMany
* @codeCoverageIgnore
@@ -345,15 +354,6 @@ class Account extends Model
$this->attributes['iban'] = Crypt::encrypt($value);
}
/**
* @codeCoverageIgnore
* Get all of the notes.
*/
public function notes()
{
return $this->morphMany(Note::class, 'noteable');
}
/**
* @codeCoverageIgnore
*