. */ declare(strict_types=1); namespace FireflyIII\Models; use FireflyIII\Support\Models\ReturnsIntegerIdTrait; use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait; use FireflyIII\User; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * @mixin IdeHelperInvitedUser */ class InvitedUser extends Model { use ReturnsIntegerIdTrait; use ReturnsIntegerUserIdTrait; protected $casts = [ 'expires' => 'datetime', 'redeemed' => 'boolean', ]; protected $fillable = ['user_id', 'email', 'invite_code', 'expires', 'redeemed']; /** * Route binder. Converts the key in the URL to the specified object (or throw 404). */ public static function routeBinder(string $value): self { if (auth()->check()) { $attemptId = (int)$value; /** @var null|InvitedUser $attempt */ $attempt = self::find($attemptId); if (null !== $attempt) { return $attempt; } } throw new NotFoundHttpException(); } public function user(): BelongsTo { return $this->belongsTo(User::class); } }