This commit is contained in:
James Cole
2023-03-09 06:33:23 +01:00
parent d4839c8818
commit 173f593a7e
32 changed files with 138 additions and 44 deletions

View File

@@ -30,6 +30,7 @@ use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class InvitedUser
@@ -38,7 +39,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @method static Builder|InvitedUser newModelQuery()
* @method static Builder|InvitedUser newQuery()
* @method static Builder|InvitedUser query()
* @mixin Eloquent
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
@@ -55,6 +55,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @method static Builder|InvitedUser whereRedeemed($value)
* @method static Builder|InvitedUser whereUpdatedAt($value)
* @method static Builder|InvitedUser whereUserId($value)
* @mixin Eloquent
*/
class InvitedUser extends Model
{
@@ -72,4 +73,25 @@ class InvitedUser extends Model
{
return $this->belongsTo(User::class);
}
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
*
* @param string $value
*
* @return WebhookAttempt
* @throws NotFoundHttpException
*/
public static function routeBinder(string $value): InvitedUser
{
if (auth()->check()) {
$attemptId = (int)$value;
/** @var InvitedUser $attempt */
$attempt = self::find($attemptId);
if (null !== $attempt) {
return $attempt;
}
}
throw new NotFoundHttpException();
}
}