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

@@ -2,11 +2,13 @@
namespace FireflyIII\Models;
use Auth;
use Carbon\Carbon;
use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Attachment
@@ -173,4 +175,15 @@ class Attachment extends Model
$this->attributes['notes'] = Crypt::encrypt($value);
}
public static function routeBinder(Attachment $value)
{
if (Auth::check()) {
if ($value->user_id == Auth::user()->id) {
return $value;
}
}
throw new NotFoundHttpException;
}
}