First code set for #330

This commit is contained in:
James Cole
2016-10-29 15:14:33 +02:00
parent ba65e982fd
commit 39749aa113
9 changed files with 473 additions and 92 deletions

View File

@@ -15,6 +15,7 @@ namespace FireflyIII\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\TransactionType
@@ -43,6 +44,25 @@ class TransactionType extends Model
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
/**
* @param string $type
*
* @return Model|null|static
*/
public static function routeBinder(string $type)
{
if (!auth()->check()) {
throw new NotFoundHttpException;
}
$transactionType = self::where('type', $type)->first();
if (!is_null($transactionType)) {
return $transactionType;
}
throw new NotFoundHttpException;
}
/**
* @return bool
*/