Communityコーディング&開発github.com

Taldres/laravel-waitlist

taldres/laravel-waitlist 統合のフロントエンドページ(サインアップフォーム、登録文言表示、確認ページ、退会ページ、設定ページ)を構築します。Laravelコントローラ(Blade、Livewire、Inertia)またはSPA/静的サイト向けのJSON API(CORS、ボット対策含む)に対応します。

laravel-waitlist とは?

このスキルは、Laravelアプリケーションに待機リスト(waitlist)機能を追加するためのパッケージ「taldres/laravel-waitlist」のフロントエンド実装を支援します。サインアップフォーム、確認ページ、退会ページ、設定ページの構築方法を、Laravelテンプレートエンジン(Blade、Livewire、Inertia)またはSPA/静的サイト向けのJSON API(CORS、ボット対策含む)の両方のアーキテクチャで詳細に説明します。パッケージから同意文言を動的に取得し、バージョンとロケールをフォームに埋め込むことで、法的に正確な同意管理を実現します。メールリンク経由のページはGETリクエストで状態を変更しない(ダブルオプトインの原則)ことや、ボット対策(Cloudflare Turnstile)の統合方法もカバーしています。また、SPA/静的サイト向けのHTTP APIエンドポイントの利用方法や、環境変数によるルーティング制御、CORS設定など、実際の本番運用に必要な設定についても網羅的に説明しています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Taldres/laravel-waitlist/tree/HEAD/resources/boost/skills/laravel-waitlist-frontend

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Laravel Waitlist: フロントエンドページ

taldres/laravel-waitlist のサインアップフォーム、確認ページ、退会ページ、または設定ページを作成または変更する際にこのスキルを使用します。

主な目標

  • フォームは登録された文言を正確に表示し、表示した内容をそのまま送信すること。メールリンク経由でアクセスされるページはGETリクエストで状態を変更しないこと。

ワークフロー

1. アーキテクチャを選択する

  • Laravelがページをレンダリングする場合 (Blade、Livewire、Inertia): コントローラから Waitlist ファサードを呼び出します。パッケージのルートはオフのままでも構いません。ただし、メールにRFC 8058のワンクリック List-Unsubscribe ヘッダーを含める必要がある場合はルートが必要です。どちらの場合でも、ページはUIをレンダリングします。
  • SPAまたは静的サイトで、ページにLaravelバックエンドを使用しない場合: WAITLIST_ROUTES_ENABLED=true を設定し、/waitlist のJSON APIを呼び出します。

どちらの場合も、プロジェクトの定義(app/Providers/WaitlistServiceProvider.php)で、メールリンクをアプリ自身のページにポイントします。環境変数の読み取りには env() ではなく config() を使用します:

$project->urls(
    confirm: config('app.frontend_url').'/waitlist/confirm/{token}',
    unsubscribe: config('app.frontend_url').'/waitlist/leave/{token}',
    manage: config('app.frontend_url').'/waitlist/preferences/{token}',
);

同じ呼び出しで、confirmed、expired、invalid、unsubscribed、erased(ユーザーがパッケージルートにPOSTした後にブラウザが遷移するページ)も指定できます。

2. サインアップフォーム

テンプレートに文言を直接記述せず、パッケージからレンダリングします:

return view('waitlist.signup', [
    'purposes' => Waitlist::purposes('default', locale: app()->getLocale()),
]);
@foreach ($purposes as $wording)
    <input type="hidden" name="purposes[{{ $wording->purpose }}][version]" value="{{ $wording->version }}">
    <input type="hidden" name="purposes[{{ $wording->purpose }}][locale]" value="{{ $wording->locale }}">
    <input type="hidden" name="purposes[{{ $wording->purpose }}][hash]" value="{{ $wording->hash() }}">

    @if ($wording->required)
        <input type="hidden" name="agreed[]" value="{{ $wording->purpose }}">
        <p>{{ $wording->text }}</p>
    @else
        <label><input type="checkbox" name="agreed[]" value="{{ $wording->purpose }}"> {{ $wording->text }}</label>
    @endif
@endforeach
use Illuminate\Support\Arr;
use Taldres\Waitlist\Exceptions\WaitlistException;
use Taldres\Waitlist\Http\Rules\PurposeChoice;
use Taldres\Waitlist\Support\RequestContext;

$validated = $request->validate([
    'email' => ['required', 'email:filter', 'max:255'],
    'purposes' => ['required', 'array'],
    'purposes.*' => ['required', new PurposeChoice],
    'agreed' => ['required', 'array'],
    'agreed.*' => ['string'],
]);

try {
    Waitlist::for('default')->add($validated['email'], Arr::only($validated['purposes'], $validated['agreed']), context: RequestContext::fromRequest($request));
} catch (WaitlistException $exception) {
    return back()->withErrors(['purposes' => $exception->getMessage()]);
}

return view('waitlist.check-your-inbox'); // 新しいアドレスと既知のアドレスで同じ応答を返す

HTTP経由: GET /waitlist/purposes?list=default&locale=de を呼び出し、その後 POST /waitlist に email、list、および purposes を {purpose: {version, locale, hash}} として送信します。応答で返された locale をそのままPOSTバックします(フォールバックロケールの場合があります)。応答: すべてのアドレスで 202、422 はフィールド名を示します。

自社サーバーから呼び出す場合(Next.js Server Actions、プロジェクトごとにトークンを持つBFFなど): トークンをサーバーサイドに保持し、各訪問者をサーバー側で制限します(APIはサーバーだけを見るため)。プロジェクトで wordingFromCallers() を使用すると、サーバーはフォームが表示した正確なテキストを {version, locale?, text} としてPOSTでき、APIからレンダリングする必要がありません。

メールアドレス以外のデータは metadata に含め、プロジェクトまたはリストで定義されたフィールドのみ許可します($project->fields(...)、リストの ->fields(...))。それ以外は 422 になります。独自のコントローラでは、Waitlist::for('default')->fields() でバリデーションします。

3. 確認ページ

メールリンクがページを開き、ページがトークンをPOSTバックします。

use Taldres\Waitlist\Exceptions\ExpiredTokenException;
use Taldres\Waitlist\Exceptions\InvalidTokenException;

try {
    Waitlist::confirm($token);
} catch (ExpiredTokenException) {
    return view('waitlist.expired');
} catch (InvalidTokenException) {
    abort(404);
}

HTTP経由: POST /waitlist/confirm/{token} に Accept: application/json ヘッダーを付けて送信すると、{"data": {..., "status": "confirmed"}} が返ります。404 は不明なトークン、410 は期限切れです。パッケージ自身の拒否は error(例: invalid_token)を返し、404 でエラーがない場合は、URLが間違っているか、ルートがオフになっているか、useWaitlist ゲートが呼び出し元をブロックしていることを意味します。

4. 退会ページ

// ページからのPOST。1つの目的のリンクには ?purpose= が付く
$purpose = $request->query('purpose');

is_string($purpose)
    ? Waitlist::withdrawConsent($token, $purpose)   // その目的のみ
    : Waitlist::unsubscribe($token);                // リストから退会

Waitlist::requestManageLink($token);                // "代わりに設定を管理": 管理リンクをメール送信

どちらも、未知のトークンに対して InvalidTokenException をスローします。

HTTP経由: POST /waitlist/unsubscribe/{token}[?purpose=] および POST /waitlist/manage-link({"token": ...} をボディに含める)。

5. 設定ページ

メールリンクの管理トークンを使用します(waitlist.manage.token_ttl 分後に期限切れ。デフォルト60分、最低1分、無制限不可):

  • GET /waitlist/manage/{token}(ステータス、現在有効な目的を取得)
  • PUT .../purposes(完全な目的セットを送信。主要な目的は維持する必要あり)
  • POST .../data(JSONコピー)
  • POST .../unsubscribe(退会)
  • POST .../erase({"confirm": true} を送信してデータ消去) 410 の場合は、新しいリンクを送信するオプションを提供します。消去前に明示的な確認を求めます。PHPでは: Waitlist::findByManageToken($token)、Waitlist::grantConsent($token, $purpose, $version, $locale) を使用します。

PUT の purposes はサインアップ時と同じ形式です。WAITLIST_REQUIRE_WORDING_HASH=true の場合、追加する目的のみ hash が必要です。維持または削除する目的には不要です。

6. 公開エンドポイントを保護する

  • サインアップおよび管理リンクに対するボットチェック(例: Cloudflare Turnstile):

    Waitlist::verifySpamUsing(fn (Request $request): bool => Http::asForm()
        ->post('https://challenges.cloudflare.com/turnstile/v0/siteverify', [
            'secret' => config('services.turnstile.secret'),
            'response' => (string) $request->input('turnstile_token'),
            'remoteip' => $request->ip(),
        ])->json('success') === true);
    

    これはパッケージのルートのみを保護します。独自のコントローラでは、自分でチェックを実装します。

  • フロントエンドが別のオリジンにある場合: config/cors.php の paths に 'waitlist', 'waitlist/*' を追加します。

  • プロキシやCDNの背後にある場合: 信頼できるプロキシを設定します。設定しないと、すべての訪問者が同じレート制限バケットを共有します。

  • オフになっているルート(デフォルト)は、レート制限やセッションが開始される前に 404 を返します。Laravelはルートが受け付けないメソッドに対しては 405 を、OPTIONS リクエストに対してはミドルウェアが実行される前に許可メソッドを返しますが、どちらも動作しません。空の WAITLIST_ROUTES_ENABLED= は設定エラーです。false はルートをオフにします。パッケージは Laravelのミドルウェア優先順位の先頭に CheckRouteConfig を配置します。後でそのリストを置き換えるアプリ(パッケージの後に起動するプロバイダの setMiddlewarePriority()、または booted())は、Taldres\Waitlist\Http\Middleware\CheckRouteConfig を最初にリストする必要があります。bootstrap/app.php の priority() では何もする必要はありません。

ルール、リファレンス、テンプレート

例

  • 「Bladeのランディングページに待機リストフォームを追加する」: コントローラで手順2から4を実装します。
  • 「Nuxtサイトに待機リストが必要」: WAITLIST_ROUTES_ENABLED=true、CORS設定、そして手順2から5のHTTP版を実装します。
  • 「待機リストフォームにTurnstileを追加する」: 手順6を実装し、フォームとともに turnstile_token を送信します。

アンチパターン

  • GETリクエストで確認や退会を行うこと。メールスキャナーはすべてのリンクをたどります。
  • 同意テキストをテンプレートに直接記述すること、またはバージョンではなくテキストをPOSTすること。
  • 応答で新しいアドレスと既知のアドレスを区別すること。
  • waitlist.routes.middleware に認証を設定すること。これはトークンリンクやワンクリック退会も保護します。クローズドなサインアップには ProjectResolver または独自のコントローラを使用し、フォームのみのチェック(CSRFやオリジンチェックなど)には waitlist.routes.group_middleware.signup を使用します。
  • オプションの目的のためにあらかじめチェックされたチェックボックス、または1つのチェックボックスで2つの目的を表現すること。

Individual skills in this repo

This repo contains 13 individual skills — each has its own dedicated page.

Taldres/laravel-waitlist

Use this skill when reviewing Laravel package compatibility across composer constraints, PHP versions, Laravel versions, Testbench versions, dependency stability lanes, Windows CI, or matrix-sensitive code and workflow changes.

Taldres/laravel-waitlist

Use this skill when creating or updating the bundled Laravel Boost skill under resources/boost/skills from the package implementation and package documentation. Trigger after public APIs, commands, config, routes, views, publish tags, README content, or examples change.

Taldres/laravel-waitlist

Use this skill when preparing Laravel package releases: CHANGELOG.md updates, generated release notes, GitHub release workflows, version checks, tags, release validation, or release automation changes. Never publish autonomously.

Taldres/laravel-waitlist

Use this skill when adding Laravel package capabilities or wiring them through the service provider: commands, migrations, routes, config merges, views, translations, assets, middleware, publish tags, workbench files, or console-only behavior.

Taldres/laravel-waitlist

Use this skill when writing, editing, fixing, or reviewing package tests with Pest 4/5 and Orchestra Testbench, including TDD, feature tests, unit tests, type coverage, arch tests, workbench behavior, commands, routes, config, migrations, and publishable resources.

Taldres/laravel-waitlist

Integrate taldres/laravel-waitlist in a Laravel application: define purposes, lists and fields, build the signup form, send the confirmation mail from events, add a preference page, and keep consent, retention and encryption intact.

Taldres/laravel-waitlist

Turn a taldres/laravel-waitlist waitlist into a launch: invite people in batches in signup order, let invited addresses register, announce the launch to everyone who agreed, and erase the list once its purpose is fulfilled.

Taldres/laravel-waitlist

Send the mails of a taldres/laravel-waitlist integration: the double opt-in confirmation, the preference page link, a welcome mail, launch mails and newsletters to the people who agreed, with the right unsubscribe links, one-click headers and a sender per project.

Taldres/laravel-waitlist

Operate a taldres/laravel-waitlist installation: answer access and erasure requests, withdraw a purpose on request, apply retention, erase a list once its purpose is fulfilled, rotate APP_KEY with waitlist:rekey, export a list, and check the setup before going live.

Taldres/laravel-waitlist

Run the waitlists of several products in one Laravel app with taldres/laravel-waitlist projects: define projects, scope facade calls with project(), resolve the project of HTTP signups, send mail per project, handle requests across all projects, or keep projects in a database for a central waitlist API.

Taldres/laravel-waitlist

Keep a newsletter tool such as Brevo, Mailchimp or Mailcoach in step with a taldres/laravel-waitlist waitlist: add confirmed contacts per purpose, remove them on withdrawal and erasure, and carry unsubscribes made at the provider back into the waitlist via a webhook.

Taldres/laravel-waitlist

Build waitlist statistics with taldres/laravel-waitlist: signups and confirmations per day for charts, totals and confirmation rates for a period, the confirmed count on any past day, and how many people are on a list right now, for dashboards, admin pages and API endpoints.

Taldres/laravel-waitlist

Write feature tests for an application's taldres/laravel-waitlist integration: get the plain tokens from events, assert the confirmation and other mails, test the signup, confirm and unsubscribe flows in PHP and over the package's HTTP routes, and bypass rate limits and bot checks in tests.

関連スキル