More bindings.

This commit is contained in:
James Cole
2016-01-09 16:09:26 +01:00
parent caa1ff120a
commit 29145bf6cf
9 changed files with 96 additions and 174 deletions

View File

@@ -1,10 +1,12 @@
<?php namespace FireflyIII\Models;
use Auth;
use Carbon\Carbon;
use Crypt;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\PiggyBank
@@ -118,4 +120,14 @@ class PiggyBank extends Model
{
$this->attributes['targetamount'] = strval(round($value, 2));
}
public static function routeBinder(PiggyBank $value)
{
if (Auth::check()) {
if ($value->account->user_id == Auth::user()->id) {
return $value;
}
}
throw new NotFoundHttpException;
}
}