Built more binders.

This commit is contained in:
James Cole
2016-01-09 15:53:11 +01:00
parent ef4e964c94
commit caa1ff120a
3 changed files with 37 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
<?php namespace FireflyIII\Models;
use Auth;
use Carbon\Carbon;
use Crypt;
use FireflyIII\Support\CacheProperties;
@@ -10,6 +11,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Watson\Validating\ValidatingTrait;
/**
@@ -525,4 +527,23 @@ class TransactionJournal extends Model
return $this->transactionType->isOpeningBalance();
}
/**
* @param $value
* @param $route
*
* @return mixed
* @throws NotFoundHttpException
*/
public static function routeBinder($value, $route)
{
if (Auth::check()) {
$object = TransactionJournal::where('id', $value)->where('user_id', Auth::user()->id)->first();
if ($object) {
return $object;
}
}
throw new NotFoundHttpException;
}
}