diff --git a/.env.example b/.env.example index 89e9463..e7d65c5 100644 --- a/.env.example +++ b/.env.example @@ -7,6 +7,7 @@ APP_URL=http://localhost # Wall-clock times from the admin UI (datetime-local) are interpreted in this zone. APP_TIMEZONE=Europe/Amsterdam +# Use nl for Dutch public UI (lang/nl.json + lang/nl/*). Admin uses the same locale when set. APP_LOCALE=en APP_FALLBACK_LOCALE=en APP_FAKER_LOCALE=en_US diff --git a/README.md b/README.md index 5ad1377..fd725b1 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,131 @@ -

Laravel Logo

+# PreRegister -

-Build Status -Total Downloads -Latest Stable Version -License -

+Laravel 11 app for festival **ticket pre-registration**: branded public landing pages, local subscriber storage, and optional sync to [Mailwizz](https://www.mailwizz.nl/) (API key per page, encrypted at rest). -## About Laravel +## Tech stack -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: +| Layer | Choice | +|--------|--------| +| Backend | PHP 8.2+, Laravel 11, MySQL 8 | +| Frontend (public + admin) | Blade, Tailwind CSS 3, Alpine.js 3 | +| Auth | Laravel Breeze (Blade stack) | +| Queue | Database driver; Mailwizz sync on `mailwizz` queue | -- [Simple, fast routing engine](https://laravel.com/docs/routing). -- [Powerful dependency injection container](https://laravel.com/docs/container). -- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. -- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). -- Database agnostic [schema migrations](https://laravel.com/docs/migrations). -- [Robust background job processing](https://laravel.com/docs/queues). -- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). +**Not used:** React, Vue, Livewire, or Inertia. -Laravel is accessible, powerful, and provides tools required for large, robust applications. +## Requirements -## Learning Laravel +- PHP ≥ 8.2 (extensions: mbstring, xml, curl, pdo_mysql, gd) +- Composer ≥ 2.7 +- Node.js ≥ 20 (for Vite / Tailwind) +- MySQL 8 (local or Docker) -Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. +## Local setup -In addition, [Laracasts](https://laracasts.com) contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. +1. **Clone and install PHP dependencies** -You can also watch bite-sized lessons with real-world projects on [Laravel Learn](https://laravel.com/learn), where you will be guided through building a Laravel application from scratch while learning PHP fundamentals. + ```bash + composer install + ``` -## Agentic Development +2. **Environment** -Laravel's predictable structure and conventions make it ideal for AI coding agents like Claude Code, Cursor, and GitHub Copilot. Install [Laravel Boost](https://laravel.com/docs/ai) to supercharge your AI workflow: + ```bash + cp .env.example .env + php artisan key:generate + ``` -```bash -composer require laravel/boost --dev + Configure database (example for Docker MySQL on localhost): -php artisan boost:install -``` + ```env + DB_CONNECTION=mysql + DB_HOST=127.0.0.1 + DB_PORT=3306 + DB_DATABASE=preregister + DB_USERNAME=preregister + DB_PASSWORD=preregister -Boost provides your agent 15+ tools and skills that help agents build Laravel applications while following best practices. + QUEUE_CONNECTION=database + ``` -## Contributing + Mailwizz API keys are **not** in `.env`; they are stored per pre-registration page in the database (encrypted). -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). +3. **Docker (optional)** -## Code of Conduct + From the project root: -In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). + ```bash + make up + # or: docker compose up -d + ``` -## Security Vulnerabilities + See [documentation/Setup.md](documentation/Setup.md) for MySQL, Mailpit, and phpMyAdmin ports. -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. +4. **Database** + + ```bash + php artisan migrate --seed + ``` + +5. **Storage link (uploads)** + + ```bash + php artisan storage:link + ``` + +6. **Frontend build** + + ```bash + npm install + npm run build + # or during development: npm run dev + ``` + +7. **Run the app** + + ```bash + php artisan serve + ``` + + Admin UI lives under `/admin` (after login). Public pre-registration URLs are `/r/{uuid-slug}`. + +8. **Queue worker (Mailwizz sync)** + + ```bash + php artisan queue:work --queue=mailwizz + ``` + + Use Supervisor or your host’s process manager in production. + +## Default login (after seed) + +`php artisan db:seed` creates a **superadmin** (via `SuperadminSeeder`): + +- Email: `admin@preregister.app` +- Password: `changeme123!` + +Change this password immediately in any shared or production environment. Additional users are created by a superadmin in **Admin → Users**. Sign in at `/login`. + +## Deployment notes + +- Run `php artisan migrate` (and `--seed` only on first deploy if you rely on seed data). +- Run `php artisan storage:link` so `public/storage` serves uploaded backgrounds and logos. +- Run a queue worker on the `mailwizz` queue (or `queue:work` without `--queue` if you only use the default queue and push jobs there consistently). +- Set `APP_KEY`, use HTTPS behind a reverse proxy, and configure `APP_URL` correctly. +- Optional: cron for `* * * * * php /path/to/artisan schedule:run` if you add scheduled tasks. + +More detail: [documentation/DEPLOYMENT-STRATEGY.md](documentation/DEPLOYMENT-STRATEGY.md). + +## Product specification + +Full functional spec and development sequence: [documentation/Pregister-Development-Prompt.md](documentation/Pregister-Development-Prompt.md). + +## Security + +- Public subscribe endpoint is rate limited (`throttle:10,1`). +- CSRF on web forms; policies for admin resources. +- Never expose Mailwizz API keys in responses, logs, or the browser. ## License -The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). +Application code follows your project’s license. Laravel is open source under the [MIT license](https://opensource.org/licenses/MIT). diff --git a/app/Http/Controllers/Auth/PasswordController.php b/app/Http/Controllers/Auth/PasswordController.php index 6916409..ce0daa4 100644 --- a/app/Http/Controllers/Auth/PasswordController.php +++ b/app/Http/Controllers/Auth/PasswordController.php @@ -1,5 +1,7 @@ Hash::make($validated['password']), ]); - return back()->with('status', 'password-updated'); + return back()->with('status', __('Password updated successfully.')); } } diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 3e5185e..14a539f 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -1,5 +1,7 @@ user()->save(); - return Redirect::route('admin.profile.edit')->with('status', 'profile-updated'); + return Redirect::route('admin.profile.edit')->with('status', __('Profile updated successfully.')); } /** diff --git a/app/Http/Requests/SubscribePublicPageRequest.php b/app/Http/Requests/SubscribePublicPageRequest.php index c04a41f..ce80c6d 100644 --- a/app/Http/Requests/SubscribePublicPageRequest.php +++ b/app/Http/Requests/SubscribePublicPageRequest.php @@ -32,6 +32,19 @@ class SubscribePublicPageRequest extends FormRequest ]; } + /** + * @return array + */ + public function attributes(): array + { + return [ + 'first_name' => __('First name'), + 'last_name' => __('Last name'), + 'email' => __('Email'), + 'phone' => __('Phone'), + ]; + } + protected function prepareForValidation(): void { $email = $this->input('email'); diff --git a/lang/en/public.php b/lang/en/public.php new file mode 100644 index 0000000..565c203 --- /dev/null +++ b/lang/en/public.php @@ -0,0 +1,7 @@ + 'Register', +]; diff --git a/lang/nl.json b/lang/nl.json new file mode 100644 index 0000000..593e13a --- /dev/null +++ b/lang/nl.json @@ -0,0 +1,18 @@ +{ + "First name": "Voornaam", + "Last name": "Achternaam", + "Email": "E-mailadres", + "Phone": "Mobiel", + "Register": "Registreren", + "days": "dagen", + "day": "dag", + "hrs": "uur", + "mins": "minuten", + "secs": "seconden", + "Sending…": "Bezig met verzenden…", + "Something went wrong. Please try again.": "Er ging iets mis. Probeer het opnieuw.", + "This pre-registration period has ended.": "Deze preregistratieperiode is afgelopen.", + "Visit ticket shop": "Ga naar de ticketshop", + "Thank you for registering!": "Bedankt voor je registratie!", + "You are already registered for this event.": "Je bent al geregistreerd voor dit evenement." +} diff --git a/lang/nl/public.php b/lang/nl/public.php new file mode 100644 index 0000000..892b99a --- /dev/null +++ b/lang/nl/public.php @@ -0,0 +1,7 @@ + 'Registreer nu!', +]; diff --git a/phpunit.xml b/phpunit.xml index e7f0a48..1fefddf 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -19,6 +19,8 @@ + + diff --git a/resources/js/app.js b/resources/js/app.js index a4da66a..0bbd2c1 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -10,6 +10,8 @@ document.addEventListener('alpine:init', () => { subscribeUrl: config.subscribeUrl, csrfToken: config.csrfToken, genericError: config.genericError, + labelDay: config.labelDay, + labelDays: config.labelDays, days: 0, hours: 0, minutes: 0, diff --git a/resources/views/admin/mailwizz/edit.blade.php b/resources/views/admin/mailwizz/edit.blade.php index a8dd5a2..5670f54 100644 --- a/resources/views/admin/mailwizz/edit.blade.php +++ b/resources/views/admin/mailwizz/edit.blade.php @@ -45,6 +45,17 @@

{{ __('Page:') }} {{ $page->title }}

+ @if ($errors->any()) + + @endif + @if ($config !== null)

{{ __('Integration active') }}

diff --git a/resources/views/layouts/admin.blade.php b/resources/views/layouts/admin.blade.php index d9a1158..302da49 100644 --- a/resources/views/layouts/admin.blade.php +++ b/resources/views/layouts/admin.blade.php @@ -13,6 +13,47 @@ @vite(['resources/css/app.css', 'resources/js/app.js']) + @php + $adminFlashSuccess = session('status'); + $adminFlashError = session('error'); + @endphp + @if ($adminFlashSuccess !== null || $adminFlashError !== null) +
+ @foreach (array_filter([ + $adminFlashSuccess !== null ? ['type' => 'success', 'message' => $adminFlashSuccess] : null, + $adminFlashError !== null ? ['type' => 'error', 'message' => $adminFlashError] : null, + ]) as $toast) +
+

{{ $toast['message'] }}

+ +
+ @endforeach +
+ @endif {{-- Mobile overlay --}}
- @if (session('status')) -
- {{ session('status') }} -
- @endif - - @if (session('error')) - - @endif - @yield('content')
diff --git a/resources/views/profile/edit.blade.php b/resources/views/profile/edit.blade.php index e0e1d38..fe6f314 100644 --- a/resources/views/profile/edit.blade.php +++ b/resources/views/profile/edit.blade.php @@ -1,29 +1,27 @@ - - -

- {{ __('Profile') }} -

-
+@extends('layouts.admin') -
-
-
-
- @include('profile.partials.update-profile-information-form') -
-
+@section('title', __('Profile')) -
-
- @include('profile.partials.update-password-form') -
-
+@section('mobile_title', __('Profile')) -
-
- @include('profile.partials.delete-user-form') -
-
+@section('content') +
+
+ ← {{ __('Back to dashboard') }} +

{{ __('Profile') }}

+

{{ __('Update your account settings and password.') }}

+
+ +
+ @include('profile.partials.update-profile-information-form') +
+ +
+ @include('profile.partials.update-password-form') +
+ +
+ @include('profile.partials.delete-user-form')
- +@endsection diff --git a/resources/views/profile/partials/update-password-form.blade.php b/resources/views/profile/partials/update-password-form.blade.php index eaca1ac..6840536 100644 --- a/resources/views/profile/partials/update-password-form.blade.php +++ b/resources/views/profile/partials/update-password-form.blade.php @@ -33,16 +33,6 @@
{{ __('Save') }} - - @if (session('status') === 'password-updated') -

{{ __('Saved.') }}

- @endif
diff --git a/resources/views/profile/partials/update-profile-information-form.blade.php b/resources/views/profile/partials/update-profile-information-form.blade.php index b507a66..8c564f7 100644 --- a/resources/views/profile/partials/update-profile-information-form.blade.php +++ b/resources/views/profile/partials/update-profile-information-form.blade.php @@ -49,16 +49,6 @@
{{ __('Save') }} - - @if (session('status') === 'profile-updated') -

{{ __('Saved.') }}

- @endif
diff --git a/resources/views/public/page.blade.php b/resources/views/public/page.blade.php index 8862136..156ba38 100644 --- a/resources/views/public/page.blade.php +++ b/resources/views/public/page.blade.php @@ -40,6 +40,8 @@ 'subscribeUrl' => route('public.subscribe', ['publicPage' => $page]), 'csrfToken' => csrf_token(), 'genericError' => __('Something went wrong. Please try again.'), + 'labelDay' => __('day'), + 'labelDays' => __('days'), ]))" > @if ($logoUrl !== null) @@ -73,7 +75,7 @@ >
-
{{ __('days') }}
+
@@ -164,7 +166,7 @@ class="mt-2 w-full rounded-lg bg-white px-4 py-3 text-sm font-semibold text-slate-900 shadow transition hover:bg-white/90 focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-slate-900 disabled:cursor-not-allowed disabled:opacity-60" :disabled="submitting" > - {{ __('Register') }} + {{ __('public.register_button') }} {{ __('Sending…') }} diff --git a/tests/Feature/Auth/RegistrationTest.php b/tests/Feature/Auth/RegistrationTest.php index 9ac4cbf..8541995 100644 --- a/tests/Feature/Auth/RegistrationTest.php +++ b/tests/Feature/Auth/RegistrationTest.php @@ -1,5 +1,7 @@ get('/register'); - $response->assertStatus(200); + $response->assertNotFound(); } - public function test_new_users_can_register(): void + public function test_registration_post_is_rejected(): void { $response = $this->post('/register', [ 'name' => 'Test User', @@ -25,7 +27,7 @@ class RegistrationTest extends TestCase 'password_confirmation' => 'password', ]); - $this->assertAuthenticated(); - $response->assertRedirect(route('admin.dashboard', absolute: false)); + $response->assertNotFound(); + $this->assertGuest(); } } diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index 8364a84..76c6340 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -10,10 +10,10 @@ class ExampleTest extends TestCase /** * A basic test example. */ - public function test_the_application_returns_a_successful_response(): void + public function test_root_redirects_to_admin_dashboard(): void { $response = $this->get('/'); - $response->assertStatus(200); + $response->assertRedirect(route('admin.dashboard', absolute: false)); } }