mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
First code set for #330
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user