mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
Clean up binders.
This commit is contained in:
18
app/User.php
18
app/User.php
@@ -32,6 +32,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Log;
|
||||
use Request;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class User.
|
||||
@@ -60,6 +61,23 @@ class User extends Authenticatable
|
||||
*/
|
||||
protected $table = 'users';
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public static function routeBinder(string $value): User
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$userId = intval($value);
|
||||
$user = self::find($userId);
|
||||
if (!is_null($user)) {
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* Link to accounts.
|
||||
|
Reference in New Issue
Block a user