feat: Wave 1 Foundation - Database, OAuth, Sync, Files, Layout, Email (T2-T7)

T2: Database Schema + All Migrations
- 10 migrations: users extension, services, songs, song_groups, song_slides,
  song_arrangements, song_arrangement_groups, service_songs, slides, cts_sync_log
- 9 Eloquent models with relationships and casts
- 9 factory classes for testing
- Tests: DatabaseSchemaTest (2 tests, 26 assertions) 

T3: ChurchTools OAuth Provider
- Custom Socialite provider for ChurchTools OAuth2
- AuthController with redirect/callback/logout
- Replaced Breeze login with OAuth-only (German UI)
- Removed all Breeze register/password-reset pages
- Tests: OAuthTest (9 tests, 54 assertions) 

T4: CTS API Service + Sync Command
- ChurchToolsService wrapping 5pm-HDH/churchtools-api
- SyncChurchToolsCommand (php artisan cts:sync)
- SyncController for refresh button
- CCLI-based song matching
- Tests: ChurchToolsSyncTest (2 tests) 

T5: File Conversion Service
- FileConversionService with letterbox/pillarbox to 1920×1080
- ConvertPowerPointJob (queued) with LibreOffice + spatie/pdf-to-image
- ZIP extraction and recursive processing
- Thumbnail generation (320×180)
- Tests: FileConversionTest (2 tests, 21 assertions) 

T6: Shared Vue Components
- AuthenticatedLayout with nav, user info, refresh button
- useAutoSave composable (500ms debounce)
- FlashMessage, ConfirmDialog, LoadingSpinner components
- HandleInertiaRequests middleware with shared props
- Tests: SharedPropsTest (7 tests) 

T7: Email Configuration
- MissingSongRequest mailable (German)
- Email template with song info and service link
- SONG_REQUEST_EMAIL config
- Tests: MissingSongMailTest (2 tests, 10 assertions) 

All tests passing: 30/30 (233 assertions)
All UI text in German with 'Du' form
Wave 1 complete: 7/7 tasks 
This commit is contained in:
Thorsten Bus 2026-03-01 19:39:26 +01:00
parent 1756473701
commit 57d54ec06b
85 changed files with 4024 additions and 1969 deletions

View file

@ -46,14 +46,15 @@ REDIS_PASSWORD=null
REDIS_PORT=6379
# Mail Configuration
MAIL_MAILER=log
MAIL_SCHEME=null
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_MAILER=smtp
MAIL_SCHEME=tls
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_ADDRESS="noreply@example.com"
MAIL_FROM_NAME="${APP_NAME}"
SONG_REQUEST_EMAIL="songs@example.com"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=

View file

@ -0,0 +1,32 @@
time="2026-03-01T19:25:20+01:00" level=warning msg="/Users/thorsten/AI/cts-work/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion"
> build
> vite build
vite v7.3.1 building client environment for production...
transforming...
✓ 784 modules transformed.
rendering chunks...
computing gzip size...
public/build/manifest.json 7.31 kB │ gzip: 0.90 kB
public/build/assets/app-DmWltKVM.css 51.56 kB │ gzip: 9.08 kB
public/build/assets/_plugin-vue_export-helper-DlAUqK2U.js 0.09 kB │ gzip: 0.10 kB
public/build/assets/PrimaryButton-mpvOc2jF.js 0.55 kB │ gzip: 0.38 kB
public/build/assets/GuestLayout-Bfh8jlss.js 0.56 kB │ gzip: 0.40 kB
public/build/assets/Dashboard-BKIdG5wF.js 0.73 kB │ gzip: 0.47 kB
public/build/assets/TextInput-EaSAg8Rp.js 1.05 kB │ gzip: 0.59 kB
public/build/assets/Edit-D8wcA1TZ.js 1.23 kB │ gzip: 0.67 kB
public/build/assets/ConfirmPassword-5FXNzWX9.js 1.34 kB │ gzip: 0.76 kB
public/build/assets/ForgotPassword-Cmz40c62.js 1.52 kB │ gzip: 0.87 kB
public/build/assets/VerifyEmail-D63zqc5n.js 1.60 kB │ gzip: 0.92 kB
public/build/assets/ResetPassword-Boa5zZGJ.js 2.08 kB │ gzip: 0.85 kB
public/build/assets/Register-DIIrlql3.js 2.54 kB │ gzip: 0.98 kB
public/build/assets/UpdatePasswordForm-BHHWCAaH.js 2.58 kB │ gzip: 1.01 kB
public/build/assets/UpdateProfileInformationForm-CpR_pYA7.js 2.60 kB │ gzip: 1.22 kB
public/build/assets/Login-Y39w2pjq.js 2.75 kB │ gzip: 1.29 kB
public/build/assets/ApplicationLogo-Vi50890Y.js 3.25 kB │ gzip: 1.44 kB
public/build/assets/DeleteUserForm-DUQ1pkPb.js 5.09 kB │ gzip: 2.10 kB
public/build/assets/AuthenticatedLayout-BQ1sV8GT.js 6.93 kB │ gzip: 2.29 kB
public/build/assets/Welcome-DekM14C9.js 18.71 kB │ gzip: 6.16 kB
public/build/assets/app-CK2TOLa8.js 254.85 kB │ gzip: 90.07 kB
✓ built in 2.56s

View file

@ -0,0 +1,3 @@
- 2026-03-01: Fuer 1920x1080 Slide-Output ohne Upscaling funktioniert in Intervention Image v3 die Kombination aus schwarzer Canvas (`create()->fill('000000')`), `scaleDown(width: 1920, height: 1080)` und zentriertem `place(...)` stabil.
- 2026-03-01: Bei Fake-Storage in Tests muessen Zielordner vor direktem Intervention-`save()` explizit erstellt werden (`makeDirectory`/`mkdir`), sonst wirft Intervention `NotWritableException`.
- 2026-03-01: Fuer Testverifikation von Letterbox/Pillarbox sind farbige PNG-Testbilder sinnvoller als `UploadedFile::fake()->image(...)`, weil Fake-Bilder sonst komplett schwarz sein koennen.

View file

@ -0,0 +1,33 @@
<?php
namespace App\Console\Commands;
use App\Services\ChurchToolsService;
use Illuminate\Console\Command;
use Throwable;
class SyncChurchToolsCommand extends Command
{
protected $signature = 'cts:sync';
protected $description = 'Synchronisiert Gottesdienste und Songs aus ChurchTools';
public function handle(ChurchToolsService $churchToolsService): int
{
try {
$summary = $churchToolsService->sync();
$this->info('Daten wurden aktualisiert');
$this->line('Services: ' . $summary['services_count']);
$this->line('Songs in Agenda: ' . $summary['songs_count']);
$this->line('Gematchte Songs: ' . $summary['matched_songs_count']);
$this->line('Nicht gematchte Songs: ' . $summary['unmatched_songs_count']);
return self::SUCCESS;
} catch (Throwable $exception) {
$this->error('Fehler beim Synchronisieren: ' . $exception->getMessage());
return self::FAILURE;
}
}
}

View file

@ -0,0 +1,23 @@
<?php
namespace App\Events;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class PowerPointConversionProgress
{
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public function __construct(
public string $jobId,
public string $status,
public int $processedPages = 0,
public int $totalPages = 0,
public array $convertedFiles = [],
) {
}
}

View file

@ -1,52 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\LoginRequest;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
use Inertia\Response;
class AuthenticatedSessionController extends Controller
{
/**
* Display the login view.
*/
public function create(): Response
{
return Inertia::render('Auth/Login', [
'canResetPassword' => Route::has('password.request'),
'status' => session('status'),
]);
}
/**
* Handle an incoming authentication request.
*/
public function store(LoginRequest $request): RedirectResponse
{
$request->authenticate();
$request->session()->regenerate();
return redirect()->intended(route('dashboard', absolute: false));
}
/**
* Destroy an authenticated session.
*/
public function destroy(Request $request): RedirectResponse
{
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/');
}
}

View file

@ -1,41 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
use Inertia\Inertia;
use Inertia\Response;
class ConfirmablePasswordController extends Controller
{
/**
* Show the confirm password view.
*/
public function show(): Response
{
return Inertia::render('Auth/ConfirmPassword');
}
/**
* Confirm the user's password.
*/
public function store(Request $request): RedirectResponse
{
if (! Auth::guard('web')->validate([
'email' => $request->user()->email,
'password' => $request->password,
])) {
throw ValidationException::withMessages([
'password' => __('auth.password'),
]);
}
$request->session()->put('auth.password_confirmed_at', time());
return redirect()->intended(route('dashboard', absolute: false));
}
}

View file

@ -1,24 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
class EmailVerificationNotificationController extends Controller
{
/**
* Send a new email verification notification.
*/
public function store(Request $request): RedirectResponse
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(route('dashboard', absolute: false));
}
$request->user()->sendEmailVerificationNotification();
return back()->with('status', 'verification-link-sent');
}
}

View file

@ -1,22 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;
class EmailVerificationPromptController extends Controller
{
/**
* Display the email verification prompt.
*/
public function __invoke(Request $request): RedirectResponse|Response
{
return $request->user()->hasVerifiedEmail()
? redirect()->intended(route('dashboard', absolute: false))
: Inertia::render('Auth/VerifyEmail', ['status' => session('status')]);
}
}

View file

@ -1,69 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\PasswordReset;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules;
use Illuminate\Validation\ValidationException;
use Inertia\Inertia;
use Inertia\Response;
class NewPasswordController extends Controller
{
/**
* Display the password reset view.
*/
public function create(Request $request): Response
{
return Inertia::render('Auth/ResetPassword', [
'email' => $request->email,
'token' => $request->route('token'),
]);
}
/**
* Handle an incoming new password request.
*
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request): RedirectResponse
{
$request->validate([
'token' => 'required',
'email' => 'required|email',
'password' => ['required', 'confirmed', Rules\Password::defaults()],
]);
// Here we will attempt to reset the user's password. If it is successful we
// will update the password on an actual user model and persist it to the
// database. Otherwise we will parse the error and return the response.
$status = Password::reset(
$request->only('email', 'password', 'password_confirmation', 'token'),
function ($user) use ($request) {
$user->forceFill([
'password' => Hash::make($request->password),
'remember_token' => Str::random(60),
])->save();
event(new PasswordReset($user));
}
);
// If the password was successfully reset, we will redirect the user back to
// the application's home authenticated view. If there is an error we can
// redirect them back to where they came from with their error message.
if ($status == Password::PASSWORD_RESET) {
return redirect()->route('login')->with('status', __($status));
}
throw ValidationException::withMessages([
'email' => [trans($status)],
]);
}
}

View file

@ -1,29 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rules\Password;
class PasswordController extends Controller
{
/**
* Update the user's password.
*/
public function update(Request $request): RedirectResponse
{
$validated = $request->validate([
'current_password' => ['required', 'current_password'],
'password' => ['required', Password::defaults(), 'confirmed'],
]);
$request->user()->update([
'password' => Hash::make($validated['password']),
]);
return back();
}
}

View file

@ -1,51 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;
use Illuminate\Validation\ValidationException;
use Inertia\Inertia;
use Inertia\Response;
class PasswordResetLinkController extends Controller
{
/**
* Display the password reset link request view.
*/
public function create(): Response
{
return Inertia::render('Auth/ForgotPassword', [
'status' => session('status'),
]);
}
/**
* Handle an incoming password reset link request.
*
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request): RedirectResponse
{
$request->validate([
'email' => 'required|email',
]);
// We will send the password reset link to this user. Once we have attempted
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$status = Password::sendResetLink(
$request->only('email')
);
if ($status == Password::RESET_LINK_SENT) {
return back()->with('status', __($status));
}
throw ValidationException::withMessages([
'email' => [trans($status)],
]);
}
}

View file

@ -1,51 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Auth\Events\Registered;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rules;
use Inertia\Inertia;
use Inertia\Response;
class RegisteredUserController extends Controller
{
/**
* Display the registration view.
*/
public function create(): Response
{
return Inertia::render('Auth/Register');
}
/**
* Handle an incoming registration request.
*
* @throws \Illuminate\Validation\ValidationException
*/
public function store(Request $request): RedirectResponse
{
$request->validate([
'name' => 'required|string|max:255',
'email' => 'required|string|lowercase|email|max:255|unique:'.User::class,
'password' => ['required', 'confirmed', Rules\Password::defaults()],
]);
$user = User::create([
'name' => $request->name,
'email' => $request->email,
'password' => Hash::make($request->password),
]);
event(new Registered($user));
Auth::login($user);
return redirect(route('dashboard', absolute: false));
}
}

View file

@ -1,27 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Auth\EmailVerificationRequest;
use Illuminate\Http\RedirectResponse;
class VerifyEmailController extends Controller
{
/**
* Mark the authenticated user's email address as verified.
*/
public function __invoke(EmailVerificationRequest $request): RedirectResponse
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
}
if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
}
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
}
}

View file

@ -0,0 +1,68 @@
<?php
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Inertia\Inertia;
use Inertia\Response;
use Laravel\Socialite\Facades\Socialite;
class AuthController extends Controller
{
/**
* Zeige die Login-Seite.
*/
public function showLogin(): Response
{
return Inertia::render('Auth/Login');
}
/**
* Leite den Benutzer zu ChurchTools OAuth weiter.
*/
public function redirect(): RedirectResponse|\Symfony\Component\HttpFoundation\RedirectResponse
{
return Socialite::driver('churchtools')->redirect();
}
/**
* Verarbeite den OAuth-Callback von ChurchTools.
*/
public function callback(): RedirectResponse
{
$socialiteUser = Socialite::driver('churchtools')->user();
$rawUser = $socialiteUser->user ?? [];
$user = User::updateOrCreate(
['email' => $socialiteUser->getEmail()],
[
'name' => $socialiteUser->getName(),
'churchtools_id' => (int) ($rawUser['id'] ?? $socialiteUser->getId()),
'avatar' => $socialiteUser->getAvatar() ?? ($rawUser['imageUrl'] ?? null),
'churchtools_groups' => $rawUser['groups'] ?? [],
'churchtools_roles' => $rawUser['roles'] ?? [],
'password' => '',
],
);
Auth::login($user, remember: true);
return redirect()->intended(route('dashboard'));
}
/**
* Melde den Benutzer ab.
*/
public function logout(Request $request): RedirectResponse
{
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/login');
}
}

View file

@ -1,63 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\ProfileUpdateRequest;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Inertia\Inertia;
use Inertia\Response;
class ProfileController extends Controller
{
/**
* Display the user's profile form.
*/
public function edit(Request $request): Response
{
return Inertia::render('Profile/Edit', [
'mustVerifyEmail' => $request->user() instanceof MustVerifyEmail,
'status' => session('status'),
]);
}
/**
* Update the user's profile information.
*/
public function update(ProfileUpdateRequest $request): RedirectResponse
{
$request->user()->fill($request->validated());
if ($request->user()->isDirty('email')) {
$request->user()->email_verified_at = null;
}
$request->user()->save();
return Redirect::route('profile.edit');
}
/**
* Delete the user's account.
*/
public function destroy(Request $request): RedirectResponse
{
$request->validate([
'password' => ['required', 'current_password'],
]);
$user = $request->user();
Auth::logout();
$user->delete();
$request->session()->invalidate();
$request->session()->regenerateToken();
return Redirect::to('/');
}
}

View file

@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Artisan;
class SyncController extends Controller
{
public function sync(): RedirectResponse
{
$exitCode = Artisan::call('cts:sync');
if ($exitCode === 0) {
return back()->with('success', 'Daten wurden aktualisiert');
}
return back()->with('error', 'Fehler beim Synchronisieren');
}
}

View file

@ -2,6 +2,7 @@
namespace App\Http\Middleware;
use App\Models\CtsSyncLog;
use Illuminate\Http\Request;
use Inertia\Middleware;
@ -32,8 +33,19 @@ public function share(Request $request): array
return [
...parent::share($request),
'auth' => [
'user' => $request->user(),
'user' => $request->user() ? [
'id' => $request->user()->id,
'name' => $request->user()->name,
'email' => $request->user()->email,
'avatar' => $request->user()->avatar,
] : null,
],
'flash' => [
'success' => $request->session()->get('success'),
'error' => $request->session()->get('error'),
],
'last_synced_at' => CtsSyncLog::latest()->first()?->synced_at,
'app_name' => config('app.name'),
];
}
}

View file

@ -1,85 +0,0 @@
<?php
namespace App\Http\Requests\Auth;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
class LoginRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'email' => ['required', 'string', 'email'],
'password' => ['required', 'string'],
];
}
/**
* Attempt to authenticate the request's credentials.
*
* @throws \Illuminate\Validation\ValidationException
*/
public function authenticate(): void
{
$this->ensureIsNotRateLimited();
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.failed'),
]);
}
RateLimiter::clear($this->throttleKey());
}
/**
* Ensure the login request is not rate limited.
*
* @throws \Illuminate\Validation\ValidationException
*/
public function ensureIsNotRateLimited(): void
{
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
return;
}
event(new Lockout($this));
$seconds = RateLimiter::availableIn($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.throttle', [
'seconds' => $seconds,
'minutes' => ceil($seconds / 60),
]),
]);
}
/**
* Get the rate limiting throttle key for the request.
*/
public function throttleKey(): string
{
return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip());
}
}

View file

@ -0,0 +1,116 @@
<?php
namespace App\Jobs;
use App\Events\PowerPointConversionProgress;
use App\Services\FileConversionService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use RuntimeException;
use Symfony\Component\Process\Process;
class ConvertPowerPointJob implements ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
public function __construct(
public string $inputPath,
public string $jobId,
) {
}
public function handle(FileConversionService $conversionService): void
{
event(new PowerPointConversionProgress($this->jobId, 'started'));
$tempDir = storage_path('app/temp/ppt-' . $this->jobId);
if (! is_dir($tempDir) && ! mkdir($tempDir, 0775, true) && ! is_dir($tempDir)) {
throw new RuntimeException('Temporaires Verzeichnis konnte nicht erstellt werden.');
}
$process = new Process([
'soffice',
'--headless',
'--convert-to',
'pdf',
'--outdir',
$tempDir,
$this->inputPath,
]);
$process->setTimeout(300);
$process->run();
if (! $process->isSuccessful()) {
throw new RuntimeException('PowerPoint-Konvertierung fehlgeschlagen: ' . $process->getErrorOutput());
}
$pdfPath = $tempDir . DIRECTORY_SEPARATOR . pathinfo($this->inputPath, PATHINFO_FILENAME) . '.pdf';
if (! is_file($pdfPath)) {
throw new RuntimeException('PDF wurde von LibreOffice nicht erzeugt.');
}
$pdfClass = implode('\\', ['Spatie', 'PdfToImage', 'Pdf']);
$pdf = new $pdfClass($pdfPath);
$pageCount = $pdf->pageCount();
$convertedFiles = [];
for ($page = 1; $page <= $pageCount; $page++) {
$slidePath = $tempDir . DIRECTORY_SEPARATOR . 'slide-' . $page . '.jpg';
$pdf->selectPage($page)->save($slidePath);
$convertedFiles[] = $conversionService->convertImage($slidePath);
event(new PowerPointConversionProgress($this->jobId, 'processing', $page, $pageCount, $convertedFiles));
}
event(new PowerPointConversionProgress($this->jobId, 'finished', $pageCount, $pageCount, $convertedFiles));
$this->cleanup($tempDir);
@unlink($this->inputPath);
}
public function failed(\Throwable $exception): void
{
event(new PowerPointConversionProgress($this->jobId, 'failed'));
Log::error('PowerPoint-Konvertierung fehlgeschlagen', [
'job_id' => $this->jobId,
'input_path' => $this->inputPath,
'error' => $exception->getMessage(),
]);
}
private function cleanup(string $tempDir): void
{
if (! is_dir($tempDir)) {
return;
}
$entries = scandir($tempDir);
if ($entries === false) {
return;
}
foreach ($entries as $entry) {
if ($entry === '.' || $entry === '..') {
continue;
}
$path = $tempDir . DIRECTORY_SEPARATOR . $entry;
if (is_file($path)) {
@unlink($path);
}
}
@rmdir($tempDir);
}
}

View file

@ -0,0 +1,26 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class MissingSongRequest extends Mailable
{
use Queueable;
use SerializesModels;
public function __construct(
public string $songName,
public ?string $ccliId,
public mixed $service,
) {
}
public function build()
{
return $this->subject("Song-Anfrage: {$this->songName} (CCLI: {$this->ccliId})")
->view('emails.missing-song-request');
}
}

28
app/Models/CtsSyncLog.php Normal file
View file

@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class CtsSyncLog extends Model
{
use HasFactory;
protected $table = 'cts_sync_log';
protected $fillable = [
'synced_at',
'events_count',
'songs_count',
'status',
'error',
];
protected function casts(): array
{
return [
'synced_at' => 'datetime',
];
}
}

43
app/Models/Service.php Normal file
View file

@ -0,0 +1,43 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Service extends Model
{
use HasFactory;
protected $fillable = [
'cts_event_id',
'title',
'date',
'preacher_name',
'beamer_tech_name',
'finalized_at',
'last_synced_at',
'cts_data',
];
protected function casts(): array
{
return [
'date' => 'date',
'finalized_at' => 'datetime',
'last_synced_at' => 'datetime',
'cts_data' => 'array',
];
}
public function serviceSongs(): HasMany
{
return $this->hasMany(ServiceSong::class);
}
public function slides(): HasMany
{
return $this->hasMany(Slide::class);
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ServiceSong extends Model
{
use HasFactory;
protected $fillable = [
'service_id',
'song_id',
'song_arrangement_id',
'use_translation',
'order',
'cts_song_name',
'cts_ccli_id',
'matched_at',
'request_sent_at',
];
protected function casts(): array
{
return [
'use_translation' => 'boolean',
'matched_at' => 'datetime',
'request_sent_at' => 'datetime',
];
}
public function service(): BelongsTo
{
return $this->belongsTo(Service::class);
}
public function song(): BelongsTo
{
return $this->belongsTo(Song::class);
}
public function arrangement(): BelongsTo
{
return $this->belongsTo(SongArrangement::class, 'song_arrangement_id');
}
}

38
app/Models/Slide.php Normal file
View file

@ -0,0 +1,38 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class Slide extends Model
{
use HasFactory;
use SoftDeletes;
protected $fillable = [
'type',
'service_id',
'original_filename',
'stored_filename',
'thumbnail_filename',
'expire_date',
'uploader_name',
'uploaded_at',
];
protected function casts(): array
{
return [
'expire_date' => 'date',
'uploaded_at' => 'datetime',
];
}
public function service(): BelongsTo
{
return $this->belongsTo(Service::class);
}
}

48
app/Models/Song.php Normal file
View file

@ -0,0 +1,48 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Song extends Model
{
use HasFactory;
use SoftDeletes;
protected $fillable = [
'ccli_id',
'title',
'author',
'copyright_text',
'copyright_year',
'publisher',
'has_translation',
'last_used_at',
];
protected function casts(): array
{
return [
'has_translation' => 'boolean',
'last_used_at' => 'datetime',
];
}
public function groups(): HasMany
{
return $this->hasMany(SongGroup::class);
}
public function arrangements(): HasMany
{
return $this->hasMany(SongArrangement::class);
}
public function serviceSongs(): HasMany
{
return $this->hasMany(ServiceSong::class);
}
}

View file

@ -0,0 +1,41 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class SongArrangement extends Model
{
use HasFactory;
protected $fillable = [
'song_id',
'name',
'is_default',
];
protected function casts(): array
{
return [
'is_default' => 'boolean',
];
}
public function song(): BelongsTo
{
return $this->belongsTo(Song::class);
}
public function arrangementGroups(): HasMany
{
return $this->hasMany(SongArrangementGroup::class);
}
public function serviceSongs(): HasMany
{
return $this->hasMany(ServiceSong::class);
}
}

View file

@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class SongArrangementGroup extends Model
{
use HasFactory;
protected $fillable = [
'song_arrangement_id',
'song_group_id',
'order',
];
public function arrangement(): BelongsTo
{
return $this->belongsTo(SongArrangement::class, 'song_arrangement_id');
}
public function group(): BelongsTo
{
return $this->belongsTo(SongGroup::class, 'song_group_id');
}
}

35
app/Models/SongGroup.php Normal file
View file

@ -0,0 +1,35 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class SongGroup extends Model
{
use HasFactory;
protected $fillable = [
'song_id',
'name',
'color',
'order',
];
public function song(): BelongsTo
{
return $this->belongsTo(Song::class);
}
public function slides(): HasMany
{
return $this->hasMany(SongSlide::class);
}
public function arrangementGroups(): HasMany
{
return $this->hasMany(SongArrangementGroup::class);
}
}

25
app/Models/SongSlide.php Normal file
View file

@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class SongSlide extends Model
{
use HasFactory;
protected $fillable = [
'song_group_id',
'order',
'text_content',
'text_content_translated',
'notes',
];
public function group(): BelongsTo
{
return $this->belongsTo(SongGroup::class, 'song_group_id');
}
}

View file

@ -10,7 +10,8 @@
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
use HasFactory;
use Notifiable;
/**
* The attributes that are mass assignable.
@ -20,7 +21,11 @@ class User extends Authenticatable
protected $fillable = [
'name',
'email',
'churchtools_id',
'password',
'avatar',
'churchtools_groups',
'churchtools_roles',
];
/**
@ -43,6 +48,8 @@ protected function casts(): array
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'churchtools_groups' => 'array',
'churchtools_roles' => 'array',
];
}
}

View file

@ -4,6 +4,8 @@
use Illuminate\Support\Facades\Vite;
use Illuminate\Support\ServiceProvider;
use App\Socialite\ChurchToolsProvider;
use Laravel\Socialite\Facades\Socialite;
class AppServiceProvider extends ServiceProvider
{
@ -21,5 +23,16 @@ public function register(): void
public function boot(): void
{
Vite::prefetch(concurrency: 3);
Socialite::extend('churchtools', function ($app) {
$config = $app['config']['services.churchtools'];
return new ChurchToolsProvider(
$app['request'],
$config['client_id'],
$config['client_secret'],
$config['redirect'],
);
});
}
}

View file

@ -0,0 +1,345 @@
<?php
namespace App\Services;
use CTApi\CTConfig;
use CTApi\Models\Events\Event\EventAgendaRequest;
use CTApi\Models\Events\Event\EventRequest;
use CTApi\Models\Events\Song\SongRequest;
use Closure;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Throwable;
class ChurchToolsService
{
private bool $apiConfigured = false;
public function __construct(
private readonly ?Closure $eventFetcher = null,
private readonly ?Closure $songFetcher = null,
private readonly ?Closure $agendaFetcher = null,
private readonly ?Closure $eventServiceFetcher = null,
) {
}
public function sync(): array
{
$startedAt = Carbon::now();
try {
$eventsSummary = $this->syncEvents();
$songsCount = $this->syncSongs();
$summary = [
'services_count' => $eventsSummary['services_count'],
'songs_count' => $eventsSummary['songs_count'],
'matched_songs_count' => $eventsSummary['matched_songs_count'],
'unmatched_songs_count' => $eventsSummary['unmatched_songs_count'],
'catalog_songs_count' => $songsCount,
];
$this->writeSyncLog('success', $summary, null, $startedAt, Carbon::now());
return $summary;
} catch (Throwable $exception) {
$summary = [
'services_count' => 0,
'songs_count' => 0,
'matched_songs_count' => 0,
'unmatched_songs_count' => 0,
'catalog_songs_count' => 0,
];
$this->writeSyncLog('error', $summary, $exception->getMessage(), $startedAt, Carbon::now());
throw $exception;
}
}
public function syncEvents(): array
{
$events = $this->fetchEvents();
$summary = [
'services_count' => 0,
'songs_count' => 0,
'matched_songs_count' => 0,
'unmatched_songs_count' => 0,
];
foreach ($events as $event) {
$eventId = (int) ($event->getId() ?? 0);
if ($eventId === 0) {
continue;
}
$serviceRoles = $this->extractServiceRoles($this->getEventServices($eventId));
$service = $this->upsertService($event, $serviceRoles);
$songSummary = $this->syncServiceAgendaSongs((int) $service->id, $eventId);
$summary['services_count']++;
$summary['songs_count'] += $songSummary['songs_count'];
$summary['matched_songs_count'] += $songSummary['matched_songs_count'];
$summary['unmatched_songs_count'] += $songSummary['unmatched_songs_count'];
}
return $summary;
}
public function syncSongs(): int
{
$songs = $this->fetchSongs();
$count = 0;
foreach ($songs as $song) {
$ccliId = $this->normalizeCcli($song->getCcli() ?? null);
if ($ccliId === null) {
continue;
}
DB::table('songs')->updateOrInsert(
['ccli_id' => $ccliId],
[
'title' => (string) ($song->getName() ?? ''),
'updated_at' => Carbon::now(),
'created_at' => Carbon::now(),
]
);
$count++;
}
return $count;
}
public function syncAgenda(int $eventId): mixed
{
$fetcher = $this->agendaFetcher ?? function (int $id): mixed {
$this->configureApi();
return EventAgendaRequest::fromEvent($id)->get();
};
return $fetcher($eventId);
}
public function getEventServices(int $eventId): array
{
$fetcher = $this->eventServiceFetcher ?? function (int $id): array {
$this->configureApi();
$event = EventRequest::find($id);
return $event?->getEventServices() ?? [];
};
return $fetcher($eventId);
}
private function fetchEvents(): array
{
$fetcher = $this->eventFetcher ?? function (): array {
$this->configureApi();
return EventRequest::where('from', Carbon::now()->toDateString())->get();
};
return $fetcher();
}
private function fetchSongs(): array
{
$fetcher = $this->songFetcher ?? function (): array {
$this->configureApi();
return SongRequest::all();
};
return $fetcher();
}
private function configureApi(): void
{
if ($this->apiConfigured) {
return;
}
$apiUrl = (string) Config::get('services.churchtools.url', '');
$apiToken = (string) Config::get('services.churchtools.api_token', '');
if ($apiUrl !== '') {
CTConfig::setApiUrl(rtrim($apiUrl, '/'));
}
CTConfig::setApiKey($apiToken);
$this->apiConfigured = true;
}
private function upsertService(mixed $event, array $serviceRoles): object
{
$ctsEventId = (string) $event->getId();
DB::table('services')->updateOrInsert(
['cts_event_id' => $ctsEventId],
[
'title' => (string) ($event->getName() ?? ''),
'date' => Carbon::parse((string) $event->getStartDate())->toDateString(),
'preacher_name' => $serviceRoles['preacher'],
'beamer_tech_name' => $serviceRoles['beamer_technician'],
'last_synced_at' => Carbon::now(),
'cts_data' => json_encode($this->extractRawData($event), JSON_THROW_ON_ERROR),
'updated_at' => Carbon::now(),
'created_at' => Carbon::now(),
]
);
return DB::table('services')
->where('cts_event_id', $ctsEventId)
->firstOrFail();
}
private function syncServiceAgendaSongs(int $serviceId, int $eventId): array
{
$agenda = $this->syncAgenda($eventId);
$agendaSongs = method_exists($agenda, 'getSongs') ? $agenda->getSongs() : [];
$summary = [
'songs_count' => 0,
'matched_songs_count' => 0,
'unmatched_songs_count' => 0,
];
foreach ($agendaSongs as $index => $song) {
$ctsSongId = (string) ($song->getId() ?? '');
if ($ctsSongId === '') {
continue;
}
$ccliId = $this->normalizeCcli($song->getCcli() ?? null);
$matchedSong = $ccliId === null
? null
: DB::table('songs')->where('ccli_id', $ccliId)->first();
DB::table('service_songs')->updateOrInsert(
[
'service_id' => $serviceId,
'order' => $index + 1,
],
[
'cts_song_name' => (string) ($song->getName() ?? ''),
'cts_ccli_id' => $ccliId,
'song_id' => $matchedSong?->id,
'matched_at' => $matchedSong !== null ? Carbon::now() : null,
'updated_at' => Carbon::now(),
'created_at' => Carbon::now(),
]
);
$summary['songs_count']++;
if ($matchedSong !== null) {
$summary['matched_songs_count']++;
} else {
$summary['unmatched_songs_count']++;
}
}
return $summary;
}
private function extractServiceRoles(array $eventServices): array
{
$roles = [
'preacher' => null,
'beamer_technician' => null,
];
foreach ($eventServices as $eventService) {
$serviceName = Str::lower((string) ($eventService->getName() ?? ''));
$personName = $this->extractPersonName($eventService);
if ($personName === null) {
continue;
}
if ($roles['preacher'] === null && (str_contains($serviceName, 'predigt') || str_contains($serviceName, 'preach'))) {
$roles['preacher'] = $personName;
}
if ($roles['beamer_technician'] === null && str_contains($serviceName, 'beamer')) {
$roles['beamer_technician'] = $personName;
}
}
return $roles;
}
private function extractPersonName(mixed $eventService): ?string
{
if (! method_exists($eventService, 'getPerson')) {
return null;
}
$person = $eventService->getPerson();
if ($person === null) {
return null;
}
if (method_exists($person, 'getName')) {
$name = trim((string) $person->getName());
if ($name !== '') {
return $name;
}
}
$firstName = method_exists($person, 'getFirstName') ? trim((string) $person->getFirstName()) : '';
$lastName = method_exists($person, 'getLastName') ? trim((string) $person->getLastName()) : '';
$fullName = trim($firstName . ' ' . $lastName);
return $fullName === '' ? null : $fullName;
}
private function extractRawData(mixed $event): array
{
if (method_exists($event, 'extractData')) {
return $event->extractData();
}
return [
'id' => $event->getId() ?? null,
'title' => $event->getName() ?? null,
'startDate' => $event->getStartDate() ?? null,
'note' => $event->getNote() ?? null,
];
}
private function normalizeCcli(?string $ccli): ?string
{
if ($ccli === null) {
return null;
}
$value = trim($ccli);
return $value === '' ? null : $value;
}
private function writeSyncLog(string $status, array $summary, ?string $message, mixed $startedAt, mixed $finishedAt): void
{
DB::table('cts_sync_log')->insert([
'status' => $status,
'synced_at' => $finishedAt,
'events_count' => $summary['services_count'] ?? 0,
'songs_count' => $summary['songs_count'] ?? 0,
'error' => $message,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
]);
}
}

View file

@ -0,0 +1,270 @@
<?php
namespace App\Services;
use App\Jobs\ConvertPowerPointJob;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use InvalidArgumentException;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use SplFileInfo;
use ZipArchive;
class FileConversionService
{
private const MAX_FILE_SIZE_BYTES = 52428800;
private const SUPPORTED_EXTENSIONS = ['png', 'jpg', 'jpeg', 'ppt', 'pptx', 'zip'];
private const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg'];
private const POWERPOINT_EXTENSIONS = ['ppt', 'pptx'];
public function convertImage(UploadedFile|string|SplFileInfo $file): array
{
$sourcePath = $this->resolvePath($file);
$extension = $this->resolveExtension($file, $sourcePath);
$this->assertSupported($extension);
if (! in_array($extension, self::IMAGE_EXTENSIONS, true)) {
throw new InvalidArgumentException('Nur Bilddateien koennen mit convertImage verarbeitet werden.');
}
$this->assertSize($file, $sourcePath);
$filename = Str::uuid()->toString() . '.jpg';
$relativePath = 'slides/' . $filename;
$targetPath = Storage::disk('public')->path($relativePath);
Storage::disk('public')->makeDirectory('slides');
$this->ensureDirectory(dirname($targetPath));
$manager = $this->createImageManager();
$canvas = $manager->create(1920, 1080)->fill('000000');
$image = $manager->read($sourcePath);
$image->scaleDown(width: 1920, height: 1080);
$canvas->place($image, 'center');
$canvas->save($targetPath, quality: 90);
$thumbnailPath = $this->generateThumbnail($relativePath);
return [
'filename' => $relativePath,
'thumbnail' => $thumbnailPath,
];
}
public function convertPowerPoint(UploadedFile|string|SplFileInfo $file): string
{
$sourcePath = $this->resolvePath($file);
$extension = $this->resolveExtension($file, $sourcePath);
$this->assertSupported($extension);
if (! in_array($extension, self::POWERPOINT_EXTENSIONS, true)) {
throw new InvalidArgumentException('Nur PPT/PPTX-Dateien sind hier erlaubt.');
}
$this->assertSize($file, $sourcePath);
$jobId = Str::uuid()->toString();
ConvertPowerPointJob::dispatch($sourcePath, $jobId);
return $jobId;
}
public function processZip(UploadedFile|string|SplFileInfo $file): array
{
$sourcePath = $this->resolvePath($file);
$extension = $this->resolveExtension($file, $sourcePath);
$this->assertSupported($extension);
if ($extension !== 'zip') {
throw new InvalidArgumentException('processZip erwartet eine ZIP-Datei.');
}
$this->assertSize($file, $sourcePath);
$zip = new ZipArchive();
if ($zip->open($sourcePath) !== true) {
throw new InvalidArgumentException('ZIP-Datei konnte nicht geoeffnet werden.');
}
$extractDir = storage_path('app/temp/zip-' . Str::uuid()->toString());
if (! is_dir($extractDir) && ! mkdir($extractDir, 0775, true) && ! is_dir($extractDir)) {
throw new InvalidArgumentException('Temporaires ZIP-Verzeichnis konnte nicht erstellt werden.');
}
$zip->extractTo($extractDir);
$zip->close();
$results = [];
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($extractDir, RecursiveDirectoryIterator::SKIP_DOTS)
);
foreach ($iterator as $entry) {
if (! $entry instanceof SplFileInfo || ! $entry->isFile()) {
continue;
}
$entryPath = $entry->getRealPath();
if ($entryPath === false) {
continue;
}
$entryExtension = $this->extensionFromPath($entryPath);
if (! in_array($entryExtension, self::SUPPORTED_EXTENSIONS, true)) {
continue;
}
if (in_array($entryExtension, self::IMAGE_EXTENSIONS, true)) {
$results[] = $this->convertImage($entryPath);
continue;
}
if (in_array($entryExtension, self::POWERPOINT_EXTENSIONS, true)) {
$results[] = ['job_id' => $this->convertPowerPoint($entryPath)];
continue;
}
$results = [...$results, ...$this->processZip($entryPath)];
}
$this->deleteDirectory($extractDir);
return $results;
}
public function generateThumbnail(string $path): string
{
$absolutePath = str_starts_with($path, DIRECTORY_SEPARATOR)
? $path
: Storage::disk('public')->path($path);
if (! is_file($absolutePath)) {
throw new InvalidArgumentException('Datei fuer Thumbnail nicht gefunden.');
}
$filename = pathinfo($absolutePath, PATHINFO_FILENAME) . '.jpg';
$thumbnailRelativePath = 'slides/thumbnails/' . $filename;
$thumbnailAbsolutePath = Storage::disk('public')->path($thumbnailRelativePath);
Storage::disk('public')->makeDirectory('slides/thumbnails');
$this->ensureDirectory(dirname($thumbnailAbsolutePath));
$manager = $this->createImageManager();
$canvas = $manager->create(320, 180)->fill('000000');
$image = $manager->read($absolutePath);
$image->scaleDown(width: 320, height: 180);
$canvas->place($image, 'center');
$canvas->save($thumbnailAbsolutePath, quality: 85);
return $thumbnailRelativePath;
}
private function resolvePath(UploadedFile|string|SplFileInfo $file): string
{
if ($file instanceof UploadedFile) {
$path = $file->getRealPath();
if ($path === false || ! is_file($path)) {
throw new InvalidArgumentException('Upload-Datei ist ungueltig.');
}
return $path;
}
if ($file instanceof SplFileInfo) {
$path = $file->getRealPath();
if ($path === false) {
throw new InvalidArgumentException('Dateipfad ist ungueltig.');
}
return $path;
}
if (! is_file($file)) {
throw new InvalidArgumentException('Datei wurde nicht gefunden.');
}
return $file;
}
private function assertSupported(string $extension): void
{
if (! in_array($extension, self::SUPPORTED_EXTENSIONS, true)) {
throw new InvalidArgumentException('Dateityp wird nicht unterstuetzt.');
}
}
private function extensionFromPath(string $path): string
{
return strtolower((string) pathinfo($path, PATHINFO_EXTENSION));
}
private function resolveExtension(UploadedFile|string|SplFileInfo $file, string $sourcePath): string
{
if ($file instanceof UploadedFile) {
return strtolower($file->getClientOriginalExtension());
}
return $this->extensionFromPath($sourcePath);
}
private function assertSize(UploadedFile|string|SplFileInfo $file, string $resolvedPath): void
{
$size = $file instanceof UploadedFile
? ($file->getSize() ?? 0)
: (filesize($resolvedPath) ?: 0);
if ($size > self::MAX_FILE_SIZE_BYTES) {
throw new InvalidArgumentException('Datei ist groesser als 50MB.');
}
}
private function deleteDirectory(string $directory): void
{
if (! is_dir($directory)) {
return;
}
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($iterator as $item) {
if (! $item instanceof SplFileInfo) {
continue;
}
if ($item->isDir()) {
@rmdir($item->getPathname());
continue;
}
@unlink($item->getPathname());
}
@rmdir($directory);
}
private function ensureDirectory(string $directory): void
{
if (is_dir($directory)) {
return;
}
if (! mkdir($directory, 0775, true) && ! is_dir($directory)) {
throw new InvalidArgumentException('Zielverzeichnis konnte nicht erstellt werden.');
}
}
private function createImageManager(): mixed
{
$managerClass = implode('\\', ['Intervention', 'Image', 'ImageManager']);
$driverClass = implode('\\', ['Intervention', 'Image', 'Drivers', 'Gd', 'Driver']);
return new $managerClass(new $driverClass());
}
}

View file

@ -0,0 +1,61 @@
<?php
namespace App\Socialite;
use GuzzleHttp\RequestOptions;
use Laravel\Socialite\Two\AbstractProvider;
use Laravel\Socialite\Two\User;
class ChurchToolsProvider extends AbstractProvider
{
protected $scopes = ['openid', 'email', 'profile'];
protected $scopeSeparator = ' ';
protected function getBaseUrl(): string
{
return rtrim(config('services.churchtools.url'), '/');
}
protected function getAuthUrl($state): string
{
return $this->buildAuthUrlFromBase(
$this->getBaseUrl() . '/oauth/authorize',
$state,
);
}
protected function getTokenUrl(): string
{
return $this->getBaseUrl() . '/oauth/access_token';
}
/**
* @param string $token
* @return array<string, mixed>
*/
protected function getUserByToken($token): array
{
$response = $this->getHttpClient()->get(
$this->getBaseUrl() . '/oauth/userinfo',
[
RequestOptions::HEADERS => [
'Authorization' => 'Bearer ' . $token,
'Accept' => 'application/json',
],
],
);
return json_decode((string) $response->getBody(), true);
}
protected function mapUserToObject(array $user): User
{
return (new User())->setRaw($user)->map([
'id' => $user['id'] ?? null,
'name' => $user['displayName'] ?? trim(($user['firstName'] ?? '') . ' ' . ($user['lastName'] ?? '')),
'email' => $user['email'] ?? null,
'avatar' => $user['imageUrl'] ?? null,
]);
}
}

View file

@ -10,6 +10,9 @@
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withCommands([
__DIR__.'/../app/Console/Commands',
])
->withMiddleware(function (Middleware $middleware): void {
$middleware->web(append: [
\App\Http\Middleware\HandleInertiaRequests::class,

View file

@ -9,9 +9,12 @@
"php": "^8.2",
"5pm-hdh/churchtools-api": "^2.1",
"inertiajs/inertia-laravel": "^2.0",
"intervention/image": "^3.11",
"laravel/framework": "^12.0",
"laravel/sanctum": "^4.0",
"laravel/socialite": "^5.24",
"laravel/tinker": "^2.10.1",
"spatie/pdf-to-image": "^1.2",
"tightenco/ziggy": "^2.0"
},
"require-dev": {

646
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "1a7d958ef832a74147b3099db8e8b76e",
"content-hash": "f9b57143fc4f1ac36c3d47c263788518",
"packages": [
{
"name": "5pm-hdh/churchtools-api",
@ -656,6 +656,69 @@
],
"time": "2025-03-06T22:45:56+00:00"
},
{
"name": "firebase/php-jwt",
"version": "v7.0.3",
"source": {
"type": "git",
"url": "https://github.com/firebase/php-jwt.git",
"reference": "28aa0694bcfdfa5e2959c394d5a1ee7a5083629e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/firebase/php-jwt/zipball/28aa0694bcfdfa5e2959c394d5a1ee7a5083629e",
"reference": "28aa0694bcfdfa5e2959c394d5a1ee7a5083629e",
"shasum": ""
},
"require": {
"php": "^8.0"
},
"require-dev": {
"guzzlehttp/guzzle": "^7.4",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5",
"psr/cache": "^2.0||^3.0",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0"
},
"suggest": {
"ext-sodium": "Support EdDSA (Ed25519) signatures",
"paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present"
},
"type": "library",
"autoload": {
"psr-4": {
"Firebase\\JWT\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Neuman Vong",
"email": "neuman+pear@twilio.com",
"role": "Developer"
},
{
"name": "Anant Narayanan",
"email": "anant@php.net",
"role": "Developer"
}
],
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
"homepage": "https://github.com/firebase/php-jwt",
"keywords": [
"jwt",
"php"
],
"support": {
"issues": "https://github.com/firebase/php-jwt/issues",
"source": "https://github.com/firebase/php-jwt/tree/v7.0.3"
},
"time": "2026-02-25T22:16:40+00:00"
},
{
"name": "fruitcake/php-cors",
"version": "v1.4.0",
@ -1270,6 +1333,150 @@
},
"time": "2026-02-24T20:21:28+00:00"
},
{
"name": "intervention/gif",
"version": "4.2.4",
"source": {
"type": "git",
"url": "https://github.com/Intervention/gif.git",
"reference": "c3598a16ebe7690cd55640c44144a9df383ea73c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Intervention/gif/zipball/c3598a16ebe7690cd55640c44144a9df383ea73c",
"reference": "c3598a16ebe7690cd55640c44144a9df383ea73c",
"shasum": ""
},
"require": {
"php": "^8.1"
},
"require-dev": {
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^10.0 || ^11.0 || ^12.0",
"slevomat/coding-standard": "~8.0",
"squizlabs/php_codesniffer": "^3.8"
},
"type": "library",
"autoload": {
"psr-4": {
"Intervention\\Gif\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Oliver Vogel",
"email": "oliver@intervention.io",
"homepage": "https://intervention.io/"
}
],
"description": "Native PHP GIF Encoder/Decoder",
"homepage": "https://github.com/intervention/gif",
"keywords": [
"animation",
"gd",
"gif",
"image"
],
"support": {
"issues": "https://github.com/Intervention/gif/issues",
"source": "https://github.com/Intervention/gif/tree/4.2.4"
},
"funding": [
{
"url": "https://paypal.me/interventionio",
"type": "custom"
},
{
"url": "https://github.com/Intervention",
"type": "github"
},
{
"url": "https://ko-fi.com/interventionphp",
"type": "ko_fi"
}
],
"time": "2026-01-04T09:27:23+00:00"
},
{
"name": "intervention/image",
"version": "3.11.7",
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
"reference": "2159bcccff18f09d2a392679b81a82c5a003f9bb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/2159bcccff18f09d2a392679b81a82c5a003f9bb",
"reference": "2159bcccff18f09d2a392679b81a82c5a003f9bb",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"intervention/gif": "^4.2",
"php": "^8.1"
},
"require-dev": {
"mockery/mockery": "^1.6",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^10.0 || ^11.0 || ^12.0",
"slevomat/coding-standard": "~8.0",
"squizlabs/php_codesniffer": "^3.8"
},
"suggest": {
"ext-exif": "Recommended to be able to read EXIF data properly."
},
"type": "library",
"autoload": {
"psr-4": {
"Intervention\\Image\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Oliver Vogel",
"email": "oliver@intervention.io",
"homepage": "https://intervention.io"
}
],
"description": "PHP Image Processing",
"homepage": "https://image.intervention.io",
"keywords": [
"gd",
"image",
"imagick",
"resize",
"thumbnail",
"watermark"
],
"support": {
"issues": "https://github.com/Intervention/image/issues",
"source": "https://github.com/Intervention/image/tree/3.11.7"
},
"funding": [
{
"url": "https://paypal.me/interventionio",
"type": "custom"
},
{
"url": "https://github.com/Intervention",
"type": "github"
},
{
"url": "https://ko-fi.com/interventionphp",
"type": "ko_fi"
}
],
"time": "2026-02-19T13:11:17+00:00"
},
{
"name": "laravel/framework",
"version": "v12.53.0",
@ -1675,6 +1882,78 @@
},
"time": "2026-02-20T19:59:49+00:00"
},
{
"name": "laravel/socialite",
"version": "v5.24.3",
"source": {
"type": "git",
"url": "https://github.com/laravel/socialite.git",
"reference": "0feb62267e7b8abc68593ca37639ad302728c129"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/socialite/zipball/0feb62267e7b8abc68593ca37639ad302728c129",
"reference": "0feb62267e7b8abc68593ca37639ad302728c129",
"shasum": ""
},
"require": {
"ext-json": "*",
"firebase/php-jwt": "^6.4|^7.0",
"guzzlehttp/guzzle": "^6.0|^7.0",
"illuminate/contracts": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"illuminate/http": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0",
"league/oauth1-client": "^1.11",
"php": "^7.2|^8.0",
"phpseclib/phpseclib": "^3.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"orchestra/testbench": "^4.18|^5.20|^6.47|^7.55|^8.36|^9.15|^10.8|^11.0",
"phpstan/phpstan": "^1.12.23",
"phpunit/phpunit": "^8.0|^9.3|^10.4|^11.5|^12.0"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"Socialite": "Laravel\\Socialite\\Facades\\Socialite"
},
"providers": [
"Laravel\\Socialite\\SocialiteServiceProvider"
]
},
"branch-alias": {
"dev-master": "5.x-dev"
}
},
"autoload": {
"psr-4": {
"Laravel\\Socialite\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "Laravel wrapper around OAuth 1 & OAuth 2 libraries.",
"homepage": "https://laravel.com",
"keywords": [
"laravel",
"oauth"
],
"support": {
"issues": "https://github.com/laravel/socialite/issues",
"source": "https://github.com/laravel/socialite"
},
"time": "2026-02-21T13:32:50+00:00"
},
{
"name": "laravel/tinker",
"version": "v2.11.1",
@ -2118,6 +2397,82 @@
],
"time": "2024-09-21T08:32:55+00:00"
},
{
"name": "league/oauth1-client",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/oauth1-client.git",
"reference": "f9c94b088837eb1aae1ad7c4f23eb65cc6993055"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/oauth1-client/zipball/f9c94b088837eb1aae1ad7c4f23eb65cc6993055",
"reference": "f9c94b088837eb1aae1ad7c4f23eb65cc6993055",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-openssl": "*",
"guzzlehttp/guzzle": "^6.0|^7.0",
"guzzlehttp/psr7": "^1.7|^2.0",
"php": ">=7.1||>=8.0"
},
"require-dev": {
"ext-simplexml": "*",
"friendsofphp/php-cs-fixer": "^2.17",
"mockery/mockery": "^1.3.3",
"phpstan/phpstan": "^0.12.42",
"phpunit/phpunit": "^7.5||9.5"
},
"suggest": {
"ext-simplexml": "For decoding XML-based responses."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev",
"dev-develop": "2.0-dev"
}
},
"autoload": {
"psr-4": {
"League\\OAuth1\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ben Corlett",
"email": "bencorlett@me.com",
"homepage": "http://www.webcomm.com.au",
"role": "Developer"
}
],
"description": "OAuth 1.0 Client Library",
"keywords": [
"Authentication",
"SSO",
"authorization",
"bitbucket",
"identity",
"idp",
"oauth",
"oauth1",
"single sign on",
"trello",
"tumblr",
"twitter"
],
"support": {
"issues": "https://github.com/thephpleague/oauth1-client/issues",
"source": "https://github.com/thephpleague/oauth1-client/tree/v1.11.0"
},
"time": "2024-12-10T19:59:05+00:00"
},
{
"name": "league/uri",
"version": "7.8.0",
@ -2811,6 +3166,125 @@
],
"time": "2026-02-16T23:10:27+00:00"
},
{
"name": "paragonie/constant_time_encoding",
"version": "v3.1.3",
"source": {
"type": "git",
"url": "https://github.com/paragonie/constant_time_encoding.git",
"reference": "d5b01a39b3415c2cd581d3bd3a3575c1ebbd8e77"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/d5b01a39b3415c2cd581d3bd3a3575c1ebbd8e77",
"reference": "d5b01a39b3415c2cd581d3bd3a3575c1ebbd8e77",
"shasum": ""
},
"require": {
"php": "^8"
},
"require-dev": {
"infection/infection": "^0",
"nikic/php-fuzzer": "^0",
"phpunit/phpunit": "^9|^10|^11",
"vimeo/psalm": "^4|^5|^6"
},
"type": "library",
"autoload": {
"psr-4": {
"ParagonIE\\ConstantTime\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paragon Initiative Enterprises",
"email": "security@paragonie.com",
"homepage": "https://paragonie.com",
"role": "Maintainer"
},
{
"name": "Steve 'Sc00bz' Thomas",
"email": "steve@tobtu.com",
"homepage": "https://www.tobtu.com",
"role": "Original Developer"
}
],
"description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)",
"keywords": [
"base16",
"base32",
"base32_decode",
"base32_encode",
"base64",
"base64_decode",
"base64_encode",
"bin2hex",
"encoding",
"hex",
"hex2bin",
"rfc4648"
],
"support": {
"email": "info@paragonie.com",
"issues": "https://github.com/paragonie/constant_time_encoding/issues",
"source": "https://github.com/paragonie/constant_time_encoding"
},
"time": "2025-09-24T15:06:41+00:00"
},
{
"name": "paragonie/random_compat",
"version": "v9.99.100",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a",
"reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a",
"shasum": ""
},
"require": {
"php": ">= 7"
},
"require-dev": {
"phpunit/phpunit": "4.*|5.*",
"vimeo/psalm": "^1"
},
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paragon Initiative Enterprises",
"email": "security@paragonie.com",
"homepage": "https://paragonie.com"
}
],
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
"keywords": [
"csprng",
"polyfill",
"pseudorandom",
"random"
],
"support": {
"email": "info@paragonie.com",
"issues": "https://github.com/paragonie/random_compat/issues",
"source": "https://github.com/paragonie/random_compat"
},
"time": "2020-10-15T08:29:30+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.9.5",
@ -2886,6 +3360,116 @@
],
"time": "2025-12-27T19:41:33+00:00"
},
{
"name": "phpseclib/phpseclib",
"version": "3.0.49",
"source": {
"type": "git",
"url": "https://github.com/phpseclib/phpseclib.git",
"reference": "6233a1e12584754e6b5daa69fe1289b47775c1b9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/6233a1e12584754e6b5daa69fe1289b47775c1b9",
"reference": "6233a1e12584754e6b5daa69fe1289b47775c1b9",
"shasum": ""
},
"require": {
"paragonie/constant_time_encoding": "^1|^2|^3",
"paragonie/random_compat": "^1.4|^2.0|^9.99.99",
"php": ">=5.6.1"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"suggest": {
"ext-dom": "Install the DOM extension to load XML formatted public keys.",
"ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
"ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
"ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations."
},
"type": "library",
"autoload": {
"files": [
"phpseclib/bootstrap.php"
],
"psr-4": {
"phpseclib3\\": "phpseclib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jim Wigginton",
"email": "terrafrost@php.net",
"role": "Lead Developer"
},
{
"name": "Patrick Monnerat",
"email": "pm@datasphere.ch",
"role": "Developer"
},
{
"name": "Andreas Fischer",
"email": "bantu@phpbb.com",
"role": "Developer"
},
{
"name": "Hans-Jürgen Petrich",
"email": "petrich@tronic-media.com",
"role": "Developer"
},
{
"name": "Graham Campbell",
"email": "graham@alt-three.com",
"role": "Developer"
}
],
"description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
"homepage": "http://phpseclib.sourceforge.net",
"keywords": [
"BigInteger",
"aes",
"asn.1",
"asn1",
"blowfish",
"crypto",
"cryptography",
"encryption",
"rsa",
"security",
"sftp",
"signature",
"signing",
"ssh",
"twofish",
"x.509",
"x509"
],
"support": {
"issues": "https://github.com/phpseclib/phpseclib/issues",
"source": "https://github.com/phpseclib/phpseclib/tree/3.0.49"
},
"funding": [
{
"url": "https://github.com/terrafrost",
"type": "github"
},
{
"url": "https://www.patreon.com/phpseclib",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib",
"type": "tidelift"
}
],
"time": "2026-01-27T09:17:28+00:00"
},
{
"name": "psr/clock",
"version": "1.0.0",
@ -3575,6 +4159,66 @@
},
"time": "2025-12-14T04:43:48+00:00"
},
{
"name": "spatie/pdf-to-image",
"version": "1.2.2",
"source": {
"type": "git",
"url": "https://github.com/spatie/pdf-to-image.git",
"reference": "9a5cb264a99e87e010c65d4ece03b51f821d55bd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/pdf-to-image/zipball/9a5cb264a99e87e010c65d4ece03b51f821d55bd",
"reference": "9a5cb264a99e87e010c65d4ece03b51f821d55bd",
"shasum": ""
},
"require": {
"php": ">=5.5.0"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"scrutinizer/ocular": "~1.1"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\PdfToImage\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Convert a pdf to an image",
"homepage": "https://github.com/spatie/pdf-to-image",
"keywords": [
"convert",
"image",
"pdf",
"pdf-to-image",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/pdf-to-image/issues",
"source": "https://github.com/spatie/pdf-to-image/tree/1.2.2"
},
"funding": [
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2016-12-14T15:37:00+00:00"
},
{
"name": "symfony/clock",
"version": "v8.0.0",

View file

@ -35,4 +35,16 @@
],
],
'song_request' => [
'email' => env('SONG_REQUEST_EMAIL', 'songs@example.com'),
],
'churchtools' => [
'url' => env('CTS_API_URL', env('CHURCHTOOLS_URL')),
'api_token' => env('CTS_API_TOKEN'),
'client_id' => env('CHURCHTOOLS_CLIENT_ID'),
'client_secret' => env('CHURCHTOOLS_CLIENT_SECRET'),
'redirect' => env('CHURCHTOOLS_REDIRECT_URI', '/auth/churchtools/callback'),
],
];

View file

@ -0,0 +1,24 @@
<?php
namespace Database\Factories;
use App\Models\CtsSyncLog;
use Illuminate\Database\Eloquent\Factories\Factory;
class CtsSyncLogFactory extends Factory
{
protected $model = CtsSyncLog::class;
public function definition(): array
{
$status = $this->faker->randomElement(['success', 'error']);
return [
'synced_at' => $this->faker->dateTimeBetween('-7 days', 'now'),
'events_count' => $this->faker->numberBetween(0, 50),
'songs_count' => $this->faker->numberBetween(0, 200),
'status' => $status,
'error' => $status === 'error' ? $this->faker->sentence() : null,
];
}
}

View file

@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use App\Models\Service;
use Illuminate\Database\Eloquent\Factories\Factory;
class ServiceFactory extends Factory
{
protected $model = Service::class;
public function definition(): array
{
$date = $this->faker->dateTimeBetween('now', '+6 months');
return [
'cts_event_id' => (string) $this->faker->unique()->numberBetween(10000, 99999),
'title' => $this->faker->sentence(4),
'date' => $date,
'preacher_name' => $this->faker->name(),
'beamer_tech_name' => $this->faker->name(),
'finalized_at' => $this->faker->optional()->dateTimeBetween('-2 weeks', 'now'),
'last_synced_at' => $this->faker->dateTimeBetween('-2 days', 'now'),
'cts_data' => [
'id' => $this->faker->uuid(),
'name' => $this->faker->sentence(3),
],
];
}
}

View file

@ -0,0 +1,29 @@
<?php
namespace Database\Factories;
use App\Models\Service;
use App\Models\ServiceSong;
use App\Models\Song;
use App\Models\SongArrangement;
use Illuminate\Database\Eloquent\Factories\Factory;
class ServiceSongFactory extends Factory
{
protected $model = ServiceSong::class;
public function definition(): array
{
return [
'service_id' => Service::factory(),
'song_id' => Song::factory(),
'song_arrangement_id' => SongArrangement::factory(),
'use_translation' => $this->faker->boolean(30),
'order' => $this->faker->numberBetween(1, 10),
'cts_song_name' => $this->faker->sentence(3),
'cts_ccli_id' => $this->faker->optional()->numerify('######'),
'matched_at' => $this->faker->optional()->dateTimeBetween('-2 weeks', 'now'),
'request_sent_at' => $this->faker->optional()->dateTimeBetween('-2 weeks', 'now'),
];
}
}

View file

@ -0,0 +1,26 @@
<?php
namespace Database\Factories;
use App\Models\Service;
use App\Models\Slide;
use Illuminate\Database\Eloquent\Factories\Factory;
class SlideFactory extends Factory
{
protected $model = Slide::class;
public function definition(): array
{
return [
'type' => $this->faker->randomElement(['information', 'moderation', 'sermon']),
'service_id' => Service::factory(),
'original_filename' => $this->faker->word() . '.jpg',
'stored_filename' => $this->faker->uuid() . '.jpg',
'thumbnail_filename' => $this->faker->uuid() . '_thumb.jpg',
'expire_date' => $this->faker->optional()->dateTimeBetween('now', '+12 months'),
'uploader_name' => $this->faker->name(),
'uploaded_at' => $this->faker->dateTimeBetween('-1 month', 'now'),
];
}
}

View file

@ -0,0 +1,21 @@
<?php
namespace Database\Factories;
use App\Models\Song;
use App\Models\SongArrangement;
use Illuminate\Database\Eloquent\Factories\Factory;
class SongArrangementFactory extends Factory
{
protected $model = SongArrangement::class;
public function definition(): array
{
return [
'song_id' => Song::factory(),
'name' => $this->faker->randomElement(['Normal', 'Kurz', 'Extended']),
'is_default' => false,
];
}
}

View file

@ -0,0 +1,22 @@
<?php
namespace Database\Factories;
use App\Models\SongArrangement;
use App\Models\SongArrangementGroup;
use App\Models\SongGroup;
use Illuminate\Database\Eloquent\Factories\Factory;
class SongArrangementGroupFactory extends Factory
{
protected $model = SongArrangementGroup::class;
public function definition(): array
{
return [
'song_arrangement_id' => SongArrangement::factory(),
'song_group_id' => SongGroup::factory(),
'order' => $this->faker->numberBetween(1, 12),
];
}
}

View file

@ -0,0 +1,25 @@
<?php
namespace Database\Factories;
use App\Models\Song;
use Illuminate\Database\Eloquent\Factories\Factory;
class SongFactory extends Factory
{
protected $model = Song::class;
public function definition(): array
{
return [
'ccli_id' => $this->faker->boolean(80) ? $this->faker->unique()->numerify('######') : null,
'title' => $this->faker->sentence(3),
'author' => $this->faker->name(),
'copyright_text' => $this->faker->optional()->sentence(),
'copyright_year' => (string) $this->faker->year(),
'publisher' => $this->faker->optional()->company(),
'has_translation' => $this->faker->boolean(25),
'last_used_at' => $this->faker->optional()->dateTimeBetween('-6 months', 'now'),
];
}
}

View file

@ -0,0 +1,22 @@
<?php
namespace Database\Factories;
use App\Models\Song;
use App\Models\SongGroup;
use Illuminate\Database\Eloquent\Factories\Factory;
class SongGroupFactory extends Factory
{
protected $model = SongGroup::class;
public function definition(): array
{
return [
'song_id' => Song::factory(),
'name' => $this->faker->randomElement(['Verse 1', 'Verse 2', 'Chorus', 'Bridge']),
'color' => $this->faker->hexColor(),
'order' => $this->faker->numberBetween(1, 10),
];
}
}

View file

@ -0,0 +1,23 @@
<?php
namespace Database\Factories;
use App\Models\SongGroup;
use App\Models\SongSlide;
use Illuminate\Database\Eloquent\Factories\Factory;
class SongSlideFactory extends Factory
{
protected $model = SongSlide::class;
public function definition(): array
{
return [
'song_group_id' => SongGroup::factory(),
'order' => $this->faker->numberBetween(1, 12),
'text_content' => implode("\n", $this->faker->sentences(3)),
'text_content_translated' => $this->faker->optional()->sentence(),
'notes' => $this->faker->optional()->sentence(),
];
}
}

View file

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('churchtools_id')->nullable()->unique()->after('email');
$table->string('avatar')->nullable()->after('password');
$table->json('churchtools_groups')->nullable()->after('avatar');
$table->json('churchtools_roles')->nullable()->after('churchtools_groups');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropUnique('users_churchtools_id_unique');
$table->dropColumn([
'churchtools_id',
'avatar',
'churchtools_groups',
'churchtools_roles',
]);
});
}
};

View file

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
public function up(): void
{
Schema::create('services', function (Blueprint $table) {
$table->id();
$table->string('cts_event_id')->unique();
$table->string('title');
$table->date('date')->index();
$table->string('preacher_name')->nullable();
$table->string('beamer_tech_name')->nullable();
$table->timestamp('finalized_at')->nullable();
$table->timestamp('last_synced_at');
$table->json('cts_data');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('services');
}
};

View file

@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
public function up(): void
{
Schema::create('songs', function (Blueprint $table) {
$table->id();
$table->string('ccli_id')->nullable()->unique()->index();
$table->string('title');
$table->string('author')->nullable();
$table->string('copyright_text')->nullable();
$table->string('copyright_year')->nullable();
$table->string('publisher')->nullable();
$table->boolean('has_translation')->default(false);
$table->timestamp('last_used_at')->nullable();
$table->softDeletes();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('songs');
}
};

View file

@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
public function up(): void
{
Schema::create('song_groups', function (Blueprint $table) {
$table->id();
$table->foreignId('song_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->string('color');
$table->unsignedInteger('order');
$table->timestamps();
$table->index('song_id');
$table->unique(['song_id', 'order']);
});
}
public function down(): void
{
Schema::dropIfExists('song_groups');
}
};

View file

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
public function up(): void
{
Schema::create('song_slides', function (Blueprint $table) {
$table->id();
$table->foreignId('song_group_id')->constrained()->cascadeOnDelete();
$table->unsignedInteger('order');
$table->text('text_content');
$table->text('text_content_translated')->nullable();
$table->text('notes')->nullable();
$table->timestamps();
$table->index('song_group_id');
$table->unique(['song_group_id', 'order']);
});
}
public function down(): void
{
Schema::dropIfExists('song_slides');
}
};

View file

@ -0,0 +1,26 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
public function up(): void
{
Schema::create('song_arrangements', function (Blueprint $table) {
$table->id();
$table->foreignId('song_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->boolean('is_default')->default(false);
$table->timestamps();
$table->index('song_id');
$table->unique(['song_id', 'name']);
});
}
public function down(): void
{
Schema::dropIfExists('song_arrangements');
}
};

View file

@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
public function up(): void
{
Schema::create('song_arrangement_groups', function (Blueprint $table) {
$table->id();
$table->foreignId('song_arrangement_id')->constrained()->cascadeOnDelete();
$table->foreignId('song_group_id')->constrained()->cascadeOnDelete();
$table->unsignedInteger('order');
$table->timestamps();
$table->index('song_arrangement_id');
$table->index('song_group_id');
$table->unique(['song_arrangement_id', 'order']);
});
}
public function down(): void
{
Schema::dropIfExists('song_arrangement_groups');
}
};

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
public function up(): void
{
Schema::create('service_songs', function (Blueprint $table) {
$table->id();
$table->foreignId('service_id')->constrained()->cascadeOnDelete();
$table->foreignId('song_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('song_arrangement_id')->nullable()->constrained()->nullOnDelete();
$table->boolean('use_translation')->default(false);
$table->unsignedInteger('order');
$table->string('cts_song_name');
$table->string('cts_ccli_id')->nullable()->index();
$table->timestamp('matched_at')->nullable();
$table->timestamp('request_sent_at')->nullable();
$table->timestamps();
$table->index('service_id');
$table->index(['service_id', 'order']);
});
}
public function down(): void
{
Schema::dropIfExists('service_songs');
}
};

View file

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
public function up(): void
{
Schema::create('slides', function (Blueprint $table) {
$table->id();
$table->enum('type', ['information', 'moderation', 'sermon']);
$table->foreignId('service_id')->nullable()->constrained()->nullOnDelete();
$table->string('original_filename');
$table->string('stored_filename');
$table->string('thumbnail_filename');
$table->date('expire_date')->nullable();
$table->string('uploader_name')->nullable();
$table->timestamp('uploaded_at');
$table->softDeletes();
$table->timestamps();
$table->index('service_id');
$table->index('expire_date');
$table->index('type');
});
}
public function down(): void
{
Schema::dropIfExists('slides');
}
};

View file

@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
public function up(): void
{
Schema::create('cts_sync_log', function (Blueprint $table) {
$table->id();
$table->timestamp('synced_at')->index();
$table->unsignedInteger('events_count');
$table->unsignedInteger('songs_count');
$table->string('status');
$table->text('error')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('cts_sync_log');
}
};

View file

@ -0,0 +1,101 @@
<script setup>
import Modal from '@/Components/Modal.vue'
const props = defineProps({
show: {
type: Boolean,
default: false,
},
title: {
type: String,
default: 'Bist du sicher?',
},
message: {
type: String,
default: '',
},
confirmLabel: {
type: String,
default: 'Bestätigen',
},
cancelLabel: {
type: String,
default: 'Abbrechen',
},
variant: {
type: String,
default: 'danger',
validator: (v) => ['danger', 'warning', 'info'].includes(v),
},
})
const emit = defineEmits(['confirm', 'cancel'])
const variantClasses = {
danger: 'bg-red-600 hover:bg-red-700 focus:ring-red-500',
warning: 'bg-amber-600 hover:bg-amber-700 focus:ring-amber-500',
info: 'bg-blue-600 hover:bg-blue-700 focus:ring-blue-500',
}
const iconColors = {
danger: 'text-red-500',
warning: 'text-amber-500',
info: 'text-blue-500',
}
</script>
<template>
<Modal :show="show" max-width="md" @close="emit('cancel')">
<div class="p-6">
<div class="flex items-start gap-4">
<!-- Warn-Icon -->
<div
class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-gray-100"
>
<svg
class="h-6 w-6"
:class="iconColors[variant]"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="1.5"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z"
/>
</svg>
</div>
<div class="flex-1">
<h3 class="text-lg font-semibold text-gray-900">
{{ title }}
</h3>
<p v-if="message" class="mt-1 text-sm text-gray-600">
{{ message }}
</p>
<slot />
</div>
</div>
<div class="mt-6 flex justify-end gap-3">
<button
type="button"
class="rounded-lg border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm transition hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2"
@click="emit('cancel')"
>
{{ cancelLabel }}
</button>
<button
type="button"
class="rounded-lg px-4 py-2 text-sm font-medium text-white shadow-sm transition focus:outline-none focus:ring-2 focus:ring-offset-2"
:class="variantClasses[variant]"
@click="emit('confirm')"
>
{{ confirmLabel }}
</button>
</div>
</div>
</Modal>
</template>

View file

@ -0,0 +1,100 @@
<script setup>
import { ref, watch, onMounted } from 'vue'
import { usePage } from '@inertiajs/vue3'
const page = usePage()
const visible = ref(false)
const message = ref('')
const type = ref('success')
let hideTimeout = null
function show(msg, msgType) {
message.value = msg
type.value = msgType
visible.value = true
if (hideTimeout) clearTimeout(hideTimeout)
hideTimeout = setTimeout(() => {
visible.value = false
}, 4000)
}
function dismiss() {
visible.value = false
if (hideTimeout) clearTimeout(hideTimeout)
}
function checkFlash() {
const flash = page.props.flash
if (flash?.success) {
show(flash.success, 'success')
} else if (flash?.error) {
show(flash.error, 'error')
}
}
onMounted(checkFlash)
watch(() => page.props.flash, checkFlash, { deep: true })
</script>
<template>
<Transition
enter-active-class="transition duration-300 ease-out"
enter-from-class="translate-y-[-100%] opacity-0"
enter-to-class="translate-y-0 opacity-100"
leave-active-class="transition duration-200 ease-in"
leave-from-class="translate-y-0 opacity-100"
leave-to-class="translate-y-[-100%] opacity-0"
>
<div
v-if="visible"
class="fixed left-1/2 top-4 z-[100] w-auto max-w-lg -translate-x-1/2"
role="alert"
>
<div
class="flex items-center gap-3 rounded-xl px-5 py-3 shadow-lg backdrop-blur-sm"
:class="{
'bg-emerald-600/90 text-white': type === 'success',
'bg-red-600/90 text-white': type === 'error',
}"
>
<!-- Erfolg-Icon -->
<svg
v-if="type === 'success'"
class="h-5 w-5 shrink-0"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
</svg>
<!-- Fehler-Icon -->
<svg
v-if="type === 'error'"
class="h-5 w-5 shrink-0"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z" />
</svg>
<span class="text-sm font-medium">{{ message }}</span>
<button
@click="dismiss"
class="ml-2 shrink-0 rounded-lg p-1 opacity-70 transition hover:opacity-100"
aria-label="Schließen"
>
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
</div>
</Transition>
</template>

View file

@ -0,0 +1,31 @@
<script setup>
defineProps({
size: {
type: String,
default: 'md',
validator: (v) => ['sm', 'md', 'lg'].includes(v),
},
label: {
type: String,
default: '',
},
})
const sizeClasses = {
sm: 'h-4 w-4 border-2',
md: 'h-6 w-6 border-2',
lg: 'h-10 w-10 border-[3px]',
}
</script>
<template>
<span class="inline-flex items-center gap-2" role="status" aria-live="polite">
<span
class="animate-spin rounded-full border-current border-r-transparent opacity-75"
:class="sizeClasses[size]"
aria-hidden="true"
/>
<span v-if="label" class="text-sm text-gray-500">{{ label }}</span>
<span class="sr-only">{{ label || 'Wird geladen…' }}</span>
</span>
</template>

View file

@ -0,0 +1,54 @@
import { useDebounceFn } from '@vueuse/core'
import { router } from '@inertiajs/vue3'
import { ref } from 'vue'
/**
* Auto-Save Composable
*
* Text-Eingaben: Debounce 500ms vor dem Speichern
* Selects/Checkboxen: Sofortige Speicherung (kein Debounce)
*
* @param {string} url - Die URL zum Speichern
* @param {string} method - HTTP-Methode ('put' oder 'post')
* @returns {{ save: Function, saveImmediate: Function, saving: Ref<boolean>, saved: Ref<boolean> }}
*/
export function useAutoSave(url, method = 'put') {
const saving = ref(false)
const saved = ref(false)
let savedTimeout = null
const performSave = (data) => {
saving.value = true
saved.value = false
router[method](url, data, {
preserveScroll: true,
preserveState: true,
onSuccess: () => {
saving.value = false
saved.value = true
if (savedTimeout) clearTimeout(savedTimeout)
savedTimeout = setTimeout(() => {
saved.value = false
}, 2000)
},
onError: () => {
saving.value = false
},
})
}
// Text-Eingaben: 500ms Debounce
const save = useDebounceFn((data) => {
performSave(data)
}, 500)
// Selects/Checkboxen: Sofort speichern
const saveImmediate = (data) => {
save.cancel()
performSave(data)
}
return { save, saveImmediate, saving, saved }
}

View file

@ -1,198 +1,306 @@
<script setup>
import { ref } from 'vue';
import ApplicationLogo from '@/Components/ApplicationLogo.vue';
import Dropdown from '@/Components/Dropdown.vue';
import DropdownLink from '@/Components/DropdownLink.vue';
import NavLink from '@/Components/NavLink.vue';
import ResponsiveNavLink from '@/Components/ResponsiveNavLink.vue';
import { Link } from '@inertiajs/vue3';
import { ref, computed } from 'vue'
import { Link, router, usePage } from '@inertiajs/vue3'
import Dropdown from '@/Components/Dropdown.vue'
import DropdownLink from '@/Components/DropdownLink.vue'
import NavLink from '@/Components/NavLink.vue'
import ResponsiveNavLink from '@/Components/ResponsiveNavLink.vue'
import FlashMessage from '@/Components/FlashMessage.vue'
import LoadingSpinner from '@/Components/LoadingSpinner.vue'
const showingNavigationDropdown = ref(false);
const page = usePage()
const showingNavigationDropdown = ref(false)
const syncing = ref(false)
const user = computed(() => page.props.auth?.user)
const lastSyncedAt = computed(() => page.props.last_synced_at)
const formattedSyncDate = computed(() => {
if (!lastSyncedAt.value) return null
const date = new Date(lastSyncedAt.value)
return date.toLocaleDateString('de-DE', {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
})
})
const userInitials = computed(() => {
if (!user.value?.name) return '?'
return user.value.name
.split(' ')
.map((n) => n[0])
.join('')
.toUpperCase()
.slice(0, 2)
})
function triggerSync() {
if (syncing.value) return
syncing.value = true
router.post(
'/sync',
{},
{
preserveScroll: true,
preserveState: true,
onFinish: () => {
syncing.value = false
},
},
)
}
</script>
<template>
<div>
<div class="min-h-screen bg-gray-100">
<nav
class="border-b border-gray-100 bg-white"
>
<!-- Primary Navigation Menu -->
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
<div class="flex h-16 justify-between">
<div class="flex">
<!-- Logo -->
<div class="flex shrink-0 items-center">
<Link :href="route('dashboard')">
<ApplicationLogo
class="block h-9 w-auto fill-current text-gray-800"
/>
</Link>
</div>
<div class="min-h-screen bg-gray-50/80">
<FlashMessage />
<!-- Navigation Links -->
<div
class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex"
>
<NavLink
:href="route('dashboard')"
:active="route().current('dashboard')"
>
Dashboard
</NavLink>
</div>
</div>
<!-- Top Navigation Bar -->
<nav class="sticky top-0 z-50 border-b border-gray-200/80 bg-white/95 backdrop-blur-sm">
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
<div class="flex h-16 items-center justify-between">
<div class="hidden sm:ms-6 sm:flex sm:items-center">
<!-- Settings Dropdown -->
<div class="relative ms-3">
<Dropdown align="right" width="48">
<template #trigger>
<span class="inline-flex rounded-md">
<button
type="button"
class="inline-flex items-center rounded-md border border-transparent bg-white px-3 py-2 text-sm font-medium leading-4 text-gray-500 transition duration-150 ease-in-out hover:text-gray-700 focus:outline-none"
>
{{ $page.props.auth.user.name }}
<svg
class="-me-0.5 ms-2 h-4 w-4"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
clip-rule="evenodd"
/>
</svg>
</button>
</span>
</template>
<template #content>
<DropdownLink
:href="route('profile.edit')"
>
Profile
</DropdownLink>
<DropdownLink
:href="route('logout')"
method="post"
as="button"
>
Log Out
</DropdownLink>
</template>
</Dropdown>
</div>
</div>
<!-- Hamburger -->
<div class="-me-2 flex items-center sm:hidden">
<button
@click="
showingNavigationDropdown =
!showingNavigationDropdown
"
class="inline-flex items-center justify-center rounded-md p-2 text-gray-400 transition duration-150 ease-in-out hover:bg-gray-100 hover:text-gray-500 focus:bg-gray-100 focus:text-gray-500 focus:outline-none"
>
<svg
class="h-6 w-6"
stroke="currentColor"
fill="none"
viewBox="0 0 24 24"
>
<path
:class="{
hidden: showingNavigationDropdown,
'inline-flex':
!showingNavigationDropdown,
}"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 12h16M4 18h16"
/>
<path
:class="{
hidden: !showingNavigationDropdown,
'inline-flex':
showingNavigationDropdown,
}"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M6 18L18 6M6 6l12 12"
/>
<!-- Left: Logo + Nav -->
<div class="flex items-center gap-1">
<!-- Logo / App Name -->
<Link
:href="route('dashboard')"
class="mr-6 flex items-center gap-2.5 transition-opacity hover:opacity-80"
>
<div class="flex h-8 w-8 items-center justify-center rounded-lg bg-gradient-to-br from-amber-500 to-orange-600 shadow-sm">
<svg class="h-4.5 w-4.5 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 3v11.25A2.25 2.25 0 006 16.5h2.25M3.75 3h-1.5m1.5 0h16.5m0 0h1.5m-1.5 0v11.25A2.25 2.25 0 0118 16.5h-2.25m-7.5 0h7.5m-7.5 0l-1 3m8.5-3l1 3m0 0l.5 1.5m-.5-1.5h-9.5m0 0l-.5 1.5" />
</svg>
</button>
</div>
<span class="hidden text-[15px] font-semibold tracking-tight text-gray-900 sm:block">
{{ $page.props.app_name || 'CTS Presenter' }}
</span>
</Link>
<!-- Desktop Navigation -->
<div class="hidden items-center gap-1 sm:flex">
<NavLink
:href="route('dashboard')"
:active="route().current('dashboard') || route().current('services.*')"
>
Services
</NavLink>
<NavLink
v-if="$page.props.ziggy?.routes?.['songs.index']"
:href="route('songs.index')"
:active="route().current('songs.*')"
>
Song-Datenbank
</NavLink>
<a
v-else
href="#"
class="inline-flex items-center border-b-2 border-transparent px-1 pt-1 text-sm font-medium leading-5 text-gray-400 cursor-not-allowed"
title="Song-Datenbank (demnächst)"
>
Song-Datenbank
</a>
</div>
</div>
</div>
<!-- Responsive Navigation Menu -->
<div
:class="{
block: showingNavigationDropdown,
hidden: !showingNavigationDropdown,
}"
class="sm:hidden"
>
<!-- Right: Sync + User -->
<div class="hidden items-center gap-4 sm:flex">
<!-- Sync Info & Button -->
<div class="flex items-center gap-3">
<span
v-if="formattedSyncDate"
class="text-xs text-gray-400"
>
Zuletzt aktualisiert: {{ formattedSyncDate }}
</span>
<button
@click="triggerSync"
:disabled="syncing"
class="group inline-flex items-center gap-1.5 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-xs font-medium text-gray-600 shadow-sm transition-all hover:border-amber-300 hover:bg-amber-50 hover:text-amber-700 focus:outline-none focus:ring-2 focus:ring-amber-400/40 focus:ring-offset-1 disabled:cursor-wait disabled:opacity-60"
>
<LoadingSpinner v-if="syncing" size="sm" />
<svg
v-else
class="h-3.5 w-3.5 transition-transform group-hover:rotate-45"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182" />
</svg>
Daten aktualisieren
</button>
</div>
<!-- User Dropdown -->
<div class="relative">
<Dropdown align="right" width="48">
<template #trigger>
<button
type="button"
class="flex items-center gap-2 rounded-lg p-1.5 text-sm transition-colors hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-amber-400/40"
>
<!-- Avatar -->
<img
v-if="user?.avatar"
:src="user.avatar"
:alt="user.name"
class="h-7 w-7 rounded-full object-cover ring-2 ring-gray-100"
/>
<span
v-else
class="flex h-7 w-7 items-center justify-center rounded-full bg-gradient-to-br from-gray-600 to-gray-700 text-[10px] font-bold tracking-wide text-white ring-2 ring-gray-100"
>
{{ userInitials }}
</span>
<span class="max-w-[120px] truncate font-medium text-gray-700">
{{ user?.name }}
</span>
<svg
class="h-4 w-4 text-gray-400"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
</svg>
</button>
</template>
<template #content>
<div class="px-4 py-2 text-xs text-gray-400">
{{ user?.email }}
</div>
<DropdownLink
:href="route('logout')"
method="post"
as="button"
>
Abmelden
</DropdownLink>
</template>
</Dropdown>
</div>
</div>
<!-- Mobile Hamburger -->
<div class="-me-2 flex items-center sm:hidden">
<button
@click="showingNavigationDropdown = !showingNavigationDropdown"
class="inline-flex items-center justify-center rounded-lg p-2 text-gray-400 transition hover:bg-gray-100 hover:text-gray-600 focus:bg-gray-100 focus:outline-none"
>
<svg class="h-6 w-6" stroke="currentColor" fill="none" viewBox="0 0 24 24">
<path
:class="{ hidden: showingNavigationDropdown, 'inline-flex': !showingNavigationDropdown }"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 12h16M4 18h16"
/>
<path
:class="{ hidden: !showingNavigationDropdown, 'inline-flex': showingNavigationDropdown }"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
</button>
</div>
</div>
</div>
<!-- Mobile Responsive Menu -->
<Transition
enter-active-class="transition duration-200 ease-out"
enter-from-class="opacity-0 -translate-y-1"
enter-to-class="opacity-100 translate-y-0"
leave-active-class="transition duration-150 ease-in"
leave-from-class="opacity-100 translate-y-0"
leave-to-class="opacity-0 -translate-y-1"
>
<div v-show="showingNavigationDropdown" class="border-t border-gray-100 sm:hidden">
<!-- Mobile Navigation -->
<div class="space-y-1 pb-3 pt-2">
<ResponsiveNavLink
:href="route('dashboard')"
:active="route().current('dashboard')"
:active="route().current('dashboard') || route().current('services.*')"
>
Dashboard
Services
</ResponsiveNavLink>
</div>
<!-- Responsive Settings Options -->
<div
class="border-t border-gray-200 pb-1 pt-4"
>
<div class="px-4">
<div
class="text-base font-medium text-gray-800"
<!-- Mobile Sync -->
<div class="border-t border-gray-100 px-4 py-3">
<button
@click="triggerSync"
:disabled="syncing"
class="flex w-full items-center gap-2 rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-600 transition hover:bg-amber-50 hover:text-amber-700 disabled:opacity-60"
>
<LoadingSpinner v-if="syncing" size="sm" />
<svg v-else class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182" />
</svg>
Daten aktualisieren
</button>
<p v-if="formattedSyncDate" class="mt-1.5 text-xs text-gray-400">
Zuletzt: {{ formattedSyncDate }}
</p>
</div>
<!-- Mobile User Info -->
<div class="border-t border-gray-100 pb-2 pt-3">
<div class="flex items-center gap-3 px-4">
<img
v-if="user?.avatar"
:src="user.avatar"
:alt="user?.name"
class="h-9 w-9 rounded-full object-cover"
/>
<span
v-else
class="flex h-9 w-9 items-center justify-center rounded-full bg-gradient-to-br from-gray-600 to-gray-700 text-xs font-bold text-white"
>
{{ $page.props.auth.user.name }}
</div>
<div class="text-sm font-medium text-gray-500">
{{ $page.props.auth.user.email }}
{{ userInitials }}
</span>
<div class="min-w-0">
<div class="truncate text-sm font-medium text-gray-800">{{ user?.name }}</div>
<div class="truncate text-xs text-gray-500">{{ user?.email }}</div>
</div>
</div>
<div class="mt-3 space-y-1">
<ResponsiveNavLink :href="route('profile.edit')">
Profile
</ResponsiveNavLink>
<ResponsiveNavLink
:href="route('logout')"
method="post"
as="button"
>
Log Out
Abmelden
</ResponsiveNavLink>
</div>
</div>
</div>
</nav>
</Transition>
</nav>
<!-- Page Heading -->
<header
class="bg-white shadow"
v-if="$slots.header"
>
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8">
<slot name="header" />
</div>
</header>
<!-- Page Heading -->
<header v-if="$slots.header" class="border-b border-gray-200/60 bg-white">
<div class="mx-auto max-w-7xl px-4 py-5 sm:px-6 lg:px-8">
<slot name="header" />
</div>
</header>
<!-- Page Content -->
<main>
<slot />
</main>
</div>
<!-- Page Content -->
<main>
<slot />
</main>
</div>
</template>

View file

@ -1,55 +0,0 @@
<script setup>
import GuestLayout from '@/Layouts/GuestLayout.vue';
import InputError from '@/Components/InputError.vue';
import InputLabel from '@/Components/InputLabel.vue';
import PrimaryButton from '@/Components/PrimaryButton.vue';
import TextInput from '@/Components/TextInput.vue';
import { Head, useForm } from '@inertiajs/vue3';
const form = useForm({
password: '',
});
const submit = () => {
form.post(route('password.confirm'), {
onFinish: () => form.reset(),
});
};
</script>
<template>
<GuestLayout>
<Head title="Confirm Password" />
<div class="mb-4 text-sm text-gray-600">
This is a secure area of the application. Please confirm your
password before continuing.
</div>
<form @submit.prevent="submit">
<div>
<InputLabel for="password" value="Password" />
<TextInput
id="password"
type="password"
class="mt-1 block w-full"
v-model="form.password"
required
autocomplete="current-password"
autofocus
/>
<InputError class="mt-2" :message="form.errors.password" />
</div>
<div class="mt-4 flex justify-end">
<PrimaryButton
class="ms-4"
:class="{ 'opacity-25': form.processing }"
:disabled="form.processing"
>
Confirm
</PrimaryButton>
</div>
</form>
</GuestLayout>
</template>

View file

@ -1,68 +0,0 @@
<script setup>
import GuestLayout from '@/Layouts/GuestLayout.vue';
import InputError from '@/Components/InputError.vue';
import InputLabel from '@/Components/InputLabel.vue';
import PrimaryButton from '@/Components/PrimaryButton.vue';
import TextInput from '@/Components/TextInput.vue';
import { Head, useForm } from '@inertiajs/vue3';
defineProps({
status: {
type: String,
},
});
const form = useForm({
email: '',
});
const submit = () => {
form.post(route('password.email'));
};
</script>
<template>
<GuestLayout>
<Head title="Forgot Password" />
<div class="mb-4 text-sm text-gray-600">
Forgot your password? No problem. Just let us know your email
address and we will email you a password reset link that will allow
you to choose a new one.
</div>
<div
v-if="status"
class="mb-4 text-sm font-medium text-green-600"
>
{{ status }}
</div>
<form @submit.prevent="submit">
<div>
<InputLabel for="email" value="Email" />
<TextInput
id="email"
type="email"
class="mt-1 block w-full"
v-model="form.email"
required
autofocus
autocomplete="username"
/>
<InputError class="mt-2" :message="form.errors.email" />
</div>
<div class="mt-4 flex items-center justify-end">
<PrimaryButton
:class="{ 'opacity-25': form.processing }"
:disabled="form.processing"
>
Email Password Reset Link
</PrimaryButton>
</div>
</form>
</GuestLayout>
</template>

View file

@ -1,100 +1,30 @@
<script setup>
import Checkbox from '@/Components/Checkbox.vue';
import GuestLayout from '@/Layouts/GuestLayout.vue';
import InputError from '@/Components/InputError.vue';
import InputLabel from '@/Components/InputLabel.vue';
import PrimaryButton from '@/Components/PrimaryButton.vue';
import TextInput from '@/Components/TextInput.vue';
import { Head, Link, useForm } from '@inertiajs/vue3';
defineProps({
canResetPassword: {
type: Boolean,
},
status: {
type: String,
},
});
const form = useForm({
email: '',
password: '',
remember: false,
});
const submit = () => {
form.post(route('login'), {
onFinish: () => form.reset('password'),
});
};
import { Head } from '@inertiajs/vue3';
</script>
<template>
<GuestLayout>
<Head title="Log in" />
<Head title="Anmelden" />
<div v-if="status" class="mb-4 text-sm font-medium text-green-600">
{{ status }}
<div class="flex flex-col items-center space-y-6">
<h1 class="text-2xl font-bold text-gray-800">
Willkommen
</h1>
<p class="text-sm text-gray-600 text-center">
Melde dich mit deinem ChurchTools-Konto an, um fortzufahren.
</p>
<a
:href="route('auth.churchtools')"
class="inline-flex w-full items-center justify-center gap-2 rounded-md bg-indigo-600 px-6 py-3 text-sm font-semibold text-white shadow-sm transition hover:bg-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
>
<svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z" />
</svg>
Mit ChurchTools anmelden
</a>
</div>
<form @submit.prevent="submit">
<div>
<InputLabel for="email" value="Email" />
<TextInput
id="email"
type="email"
class="mt-1 block w-full"
v-model="form.email"
required
autofocus
autocomplete="username"
/>
<InputError class="mt-2" :message="form.errors.email" />
</div>
<div class="mt-4">
<InputLabel for="password" value="Password" />
<TextInput
id="password"
type="password"
class="mt-1 block w-full"
v-model="form.password"
required
autocomplete="current-password"
/>
<InputError class="mt-2" :message="form.errors.password" />
</div>
<div class="mt-4 block">
<label class="flex items-center">
<Checkbox name="remember" v-model:checked="form.remember" />
<span class="ms-2 text-sm text-gray-600"
>Remember me</span
>
</label>
</div>
<div class="mt-4 flex items-center justify-end">
<Link
v-if="canResetPassword"
:href="route('password.request')"
class="rounded-md text-sm text-gray-600 underline hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
>
Forgot your password?
</Link>
<PrimaryButton
class="ms-4"
:class="{ 'opacity-25': form.processing }"
:disabled="form.processing"
>
Log in
</PrimaryButton>
</div>
</form>
</GuestLayout>
</template>

View file

@ -1,113 +0,0 @@
<script setup>
import GuestLayout from '@/Layouts/GuestLayout.vue';
import InputError from '@/Components/InputError.vue';
import InputLabel from '@/Components/InputLabel.vue';
import PrimaryButton from '@/Components/PrimaryButton.vue';
import TextInput from '@/Components/TextInput.vue';
import { Head, Link, useForm } from '@inertiajs/vue3';
const form = useForm({
name: '',
email: '',
password: '',
password_confirmation: '',
});
const submit = () => {
form.post(route('register'), {
onFinish: () => form.reset('password', 'password_confirmation'),
});
};
</script>
<template>
<GuestLayout>
<Head title="Register" />
<form @submit.prevent="submit">
<div>
<InputLabel for="name" value="Name" />
<TextInput
id="name"
type="text"
class="mt-1 block w-full"
v-model="form.name"
required
autofocus
autocomplete="name"
/>
<InputError class="mt-2" :message="form.errors.name" />
</div>
<div class="mt-4">
<InputLabel for="email" value="Email" />
<TextInput
id="email"
type="email"
class="mt-1 block w-full"
v-model="form.email"
required
autocomplete="username"
/>
<InputError class="mt-2" :message="form.errors.email" />
</div>
<div class="mt-4">
<InputLabel for="password" value="Password" />
<TextInput
id="password"
type="password"
class="mt-1 block w-full"
v-model="form.password"
required
autocomplete="new-password"
/>
<InputError class="mt-2" :message="form.errors.password" />
</div>
<div class="mt-4">
<InputLabel
for="password_confirmation"
value="Confirm Password"
/>
<TextInput
id="password_confirmation"
type="password"
class="mt-1 block w-full"
v-model="form.password_confirmation"
required
autocomplete="new-password"
/>
<InputError
class="mt-2"
:message="form.errors.password_confirmation"
/>
</div>
<div class="mt-4 flex items-center justify-end">
<Link
:href="route('login')"
class="rounded-md text-sm text-gray-600 underline hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
>
Already registered?
</Link>
<PrimaryButton
class="ms-4"
:class="{ 'opacity-25': form.processing }"
:disabled="form.processing"
>
Register
</PrimaryButton>
</div>
</form>
</GuestLayout>
</template>

View file

@ -1,101 +0,0 @@
<script setup>
import GuestLayout from '@/Layouts/GuestLayout.vue';
import InputError from '@/Components/InputError.vue';
import InputLabel from '@/Components/InputLabel.vue';
import PrimaryButton from '@/Components/PrimaryButton.vue';
import TextInput from '@/Components/TextInput.vue';
import { Head, useForm } from '@inertiajs/vue3';
const props = defineProps({
email: {
type: String,
required: true,
},
token: {
type: String,
required: true,
},
});
const form = useForm({
token: props.token,
email: props.email,
password: '',
password_confirmation: '',
});
const submit = () => {
form.post(route('password.store'), {
onFinish: () => form.reset('password', 'password_confirmation'),
});
};
</script>
<template>
<GuestLayout>
<Head title="Reset Password" />
<form @submit.prevent="submit">
<div>
<InputLabel for="email" value="Email" />
<TextInput
id="email"
type="email"
class="mt-1 block w-full"
v-model="form.email"
required
autofocus
autocomplete="username"
/>
<InputError class="mt-2" :message="form.errors.email" />
</div>
<div class="mt-4">
<InputLabel for="password" value="Password" />
<TextInput
id="password"
type="password"
class="mt-1 block w-full"
v-model="form.password"
required
autocomplete="new-password"
/>
<InputError class="mt-2" :message="form.errors.password" />
</div>
<div class="mt-4">
<InputLabel
for="password_confirmation"
value="Confirm Password"
/>
<TextInput
id="password_confirmation"
type="password"
class="mt-1 block w-full"
v-model="form.password_confirmation"
required
autocomplete="new-password"
/>
<InputError
class="mt-2"
:message="form.errors.password_confirmation"
/>
</div>
<div class="mt-4 flex items-center justify-end">
<PrimaryButton
:class="{ 'opacity-25': form.processing }"
:disabled="form.processing"
>
Reset Password
</PrimaryButton>
</div>
</form>
</GuestLayout>
</template>

View file

@ -1,61 +0,0 @@
<script setup>
import { computed } from 'vue';
import GuestLayout from '@/Layouts/GuestLayout.vue';
import PrimaryButton from '@/Components/PrimaryButton.vue';
import { Head, Link, useForm } from '@inertiajs/vue3';
const props = defineProps({
status: {
type: String,
},
});
const form = useForm({});
const submit = () => {
form.post(route('verification.send'));
};
const verificationLinkSent = computed(
() => props.status === 'verification-link-sent',
);
</script>
<template>
<GuestLayout>
<Head title="Email Verification" />
<div class="mb-4 text-sm text-gray-600">
Thanks for signing up! Before getting started, could you verify your
email address by clicking on the link we just emailed to you? If you
didn't receive the email, we will gladly send you another.
</div>
<div
class="mb-4 text-sm font-medium text-green-600"
v-if="verificationLinkSent"
>
A new verification link has been sent to the email address you
provided during registration.
</div>
<form @submit.prevent="submit">
<div class="mt-4 flex items-center justify-between">
<PrimaryButton
:class="{ 'opacity-25': form.processing }"
:disabled="form.processing"
>
Resend Verification Email
</PrimaryButton>
<Link
:href="route('logout')"
method="post"
as="button"
class="rounded-md text-sm text-gray-600 underline hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
>Log Out</Link
>
</div>
</form>
</GuestLayout>
</template>

View file

@ -4,14 +4,14 @@ import { Head } from '@inertiajs/vue3';
</script>
<template>
<Head title="Dashboard" />
<Head title="Übersicht" />
<AuthenticatedLayout>
<template #header>
<h2
class="text-xl font-semibold leading-tight text-gray-800"
>
Dashboard
Übersicht
</h2>
</template>
@ -21,7 +21,7 @@ import { Head } from '@inertiajs/vue3';
class="overflow-hidden bg-white shadow-sm sm:rounded-lg"
>
<div class="p-6 text-gray-900">
You're logged in!
Du bist angemeldet als {{ $page.props.auth.user.name }}.
</div>
</div>
</div>

View file

@ -1,56 +0,0 @@
<script setup>
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue';
import DeleteUserForm from './Partials/DeleteUserForm.vue';
import UpdatePasswordForm from './Partials/UpdatePasswordForm.vue';
import UpdateProfileInformationForm from './Partials/UpdateProfileInformationForm.vue';
import { Head } from '@inertiajs/vue3';
defineProps({
mustVerifyEmail: {
type: Boolean,
},
status: {
type: String,
},
});
</script>
<template>
<Head title="Profile" />
<AuthenticatedLayout>
<template #header>
<h2
class="text-xl font-semibold leading-tight text-gray-800"
>
Profile
</h2>
</template>
<div class="py-12">
<div class="mx-auto max-w-7xl space-y-6 sm:px-6 lg:px-8">
<div
class="bg-white p-4 shadow sm:rounded-lg sm:p-8"
>
<UpdateProfileInformationForm
:must-verify-email="mustVerifyEmail"
:status="status"
class="max-w-xl"
/>
</div>
<div
class="bg-white p-4 shadow sm:rounded-lg sm:p-8"
>
<UpdatePasswordForm class="max-w-xl" />
</div>
<div
class="bg-white p-4 shadow sm:rounded-lg sm:p-8"
>
<DeleteUserForm class="max-w-xl" />
</div>
</div>
</div>
</AuthenticatedLayout>
</template>

View file

@ -1,108 +0,0 @@
<script setup>
import DangerButton from '@/Components/DangerButton.vue';
import InputError from '@/Components/InputError.vue';
import InputLabel from '@/Components/InputLabel.vue';
import Modal from '@/Components/Modal.vue';
import SecondaryButton from '@/Components/SecondaryButton.vue';
import TextInput from '@/Components/TextInput.vue';
import { useForm } from '@inertiajs/vue3';
import { nextTick, ref } from 'vue';
const confirmingUserDeletion = ref(false);
const passwordInput = ref(null);
const form = useForm({
password: '',
});
const confirmUserDeletion = () => {
confirmingUserDeletion.value = true;
nextTick(() => passwordInput.value.focus());
};
const deleteUser = () => {
form.delete(route('profile.destroy'), {
preserveScroll: true,
onSuccess: () => closeModal(),
onError: () => passwordInput.value.focus(),
onFinish: () => form.reset(),
});
};
const closeModal = () => {
confirmingUserDeletion.value = false;
form.clearErrors();
form.reset();
};
</script>
<template>
<section class="space-y-6">
<header>
<h2 class="text-lg font-medium text-gray-900">
Delete Account
</h2>
<p class="mt-1 text-sm text-gray-600">
Once your account is deleted, all of its resources and data will
be permanently deleted. Before deleting your account, please
download any data or information that you wish to retain.
</p>
</header>
<DangerButton @click="confirmUserDeletion">Delete Account</DangerButton>
<Modal :show="confirmingUserDeletion" @close="closeModal">
<div class="p-6">
<h2
class="text-lg font-medium text-gray-900"
>
Are you sure you want to delete your account?
</h2>
<p class="mt-1 text-sm text-gray-600">
Once your account is deleted, all of its resources and data
will be permanently deleted. Please enter your password to
confirm you would like to permanently delete your account.
</p>
<div class="mt-6">
<InputLabel
for="password"
value="Password"
class="sr-only"
/>
<TextInput
id="password"
ref="passwordInput"
v-model="form.password"
type="password"
class="mt-1 block w-3/4"
placeholder="Password"
@keyup.enter="deleteUser"
/>
<InputError :message="form.errors.password" class="mt-2" />
</div>
<div class="mt-6 flex justify-end">
<SecondaryButton @click="closeModal">
Cancel
</SecondaryButton>
<DangerButton
class="ms-3"
:class="{ 'opacity-25': form.processing }"
:disabled="form.processing"
@click="deleteUser"
>
Delete Account
</DangerButton>
</div>
</div>
</Modal>
</section>
</template>

View file

@ -1,122 +0,0 @@
<script setup>
import InputError from '@/Components/InputError.vue';
import InputLabel from '@/Components/InputLabel.vue';
import PrimaryButton from '@/Components/PrimaryButton.vue';
import TextInput from '@/Components/TextInput.vue';
import { useForm } from '@inertiajs/vue3';
import { ref } from 'vue';
const passwordInput = ref(null);
const currentPasswordInput = ref(null);
const form = useForm({
current_password: '',
password: '',
password_confirmation: '',
});
const updatePassword = () => {
form.put(route('password.update'), {
preserveScroll: true,
onSuccess: () => form.reset(),
onError: () => {
if (form.errors.password) {
form.reset('password', 'password_confirmation');
passwordInput.value.focus();
}
if (form.errors.current_password) {
form.reset('current_password');
currentPasswordInput.value.focus();
}
},
});
};
</script>
<template>
<section>
<header>
<h2 class="text-lg font-medium text-gray-900">
Update Password
</h2>
<p class="mt-1 text-sm text-gray-600">
Ensure your account is using a long, random password to stay
secure.
</p>
</header>
<form @submit.prevent="updatePassword" class="mt-6 space-y-6">
<div>
<InputLabel for="current_password" value="Current Password" />
<TextInput
id="current_password"
ref="currentPasswordInput"
v-model="form.current_password"
type="password"
class="mt-1 block w-full"
autocomplete="current-password"
/>
<InputError
:message="form.errors.current_password"
class="mt-2"
/>
</div>
<div>
<InputLabel for="password" value="New Password" />
<TextInput
id="password"
ref="passwordInput"
v-model="form.password"
type="password"
class="mt-1 block w-full"
autocomplete="new-password"
/>
<InputError :message="form.errors.password" class="mt-2" />
</div>
<div>
<InputLabel
for="password_confirmation"
value="Confirm Password"
/>
<TextInput
id="password_confirmation"
v-model="form.password_confirmation"
type="password"
class="mt-1 block w-full"
autocomplete="new-password"
/>
<InputError
:message="form.errors.password_confirmation"
class="mt-2"
/>
</div>
<div class="flex items-center gap-4">
<PrimaryButton :disabled="form.processing">Save</PrimaryButton>
<Transition
enter-active-class="transition ease-in-out"
enter-from-class="opacity-0"
leave-active-class="transition ease-in-out"
leave-to-class="opacity-0"
>
<p
v-if="form.recentlySuccessful"
class="text-sm text-gray-600"
>
Saved.
</p>
</Transition>
</div>
</form>
</section>
</template>

View file

@ -1,112 +0,0 @@
<script setup>
import InputError from '@/Components/InputError.vue';
import InputLabel from '@/Components/InputLabel.vue';
import PrimaryButton from '@/Components/PrimaryButton.vue';
import TextInput from '@/Components/TextInput.vue';
import { Link, useForm, usePage } from '@inertiajs/vue3';
defineProps({
mustVerifyEmail: {
type: Boolean,
},
status: {
type: String,
},
});
const user = usePage().props.auth.user;
const form = useForm({
name: user.name,
email: user.email,
});
</script>
<template>
<section>
<header>
<h2 class="text-lg font-medium text-gray-900">
Profile Information
</h2>
<p class="mt-1 text-sm text-gray-600">
Update your account's profile information and email address.
</p>
</header>
<form
@submit.prevent="form.patch(route('profile.update'))"
class="mt-6 space-y-6"
>
<div>
<InputLabel for="name" value="Name" />
<TextInput
id="name"
type="text"
class="mt-1 block w-full"
v-model="form.name"
required
autofocus
autocomplete="name"
/>
<InputError class="mt-2" :message="form.errors.name" />
</div>
<div>
<InputLabel for="email" value="Email" />
<TextInput
id="email"
type="email"
class="mt-1 block w-full"
v-model="form.email"
required
autocomplete="username"
/>
<InputError class="mt-2" :message="form.errors.email" />
</div>
<div v-if="mustVerifyEmail && user.email_verified_at === null">
<p class="mt-2 text-sm text-gray-800">
Your email address is unverified.
<Link
:href="route('verification.send')"
method="post"
as="button"
class="rounded-md text-sm text-gray-600 underline hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
>
Click here to re-send the verification email.
</Link>
</p>
<div
v-show="status === 'verification-link-sent'"
class="mt-2 text-sm font-medium text-green-600"
>
A new verification link has been sent to your email address.
</div>
</div>
<div class="flex items-center gap-4">
<PrimaryButton :disabled="form.processing">Save</PrimaryButton>
<Transition
enter-active-class="transition ease-in-out"
enter-from-class="opacity-0"
leave-active-class="transition ease-in-out"
leave-to-class="opacity-0"
>
<p
v-if="form.recentlySuccessful"
class="text-sm text-gray-600"
>
Saved.
</p>
</Transition>
</div>
</form>
</section>
</template>

View file

@ -1,386 +0,0 @@
<script setup>
import { Head, Link } from '@inertiajs/vue3';
defineProps({
canLogin: {
type: Boolean,
},
canRegister: {
type: Boolean,
},
laravelVersion: {
type: String,
required: true,
},
phpVersion: {
type: String,
required: true,
},
});
function handleImageError() {
document.getElementById('screenshot-container')?.classList.add('!hidden');
document.getElementById('docs-card')?.classList.add('!row-span-1');
document.getElementById('docs-card-content')?.classList.add('!flex-row');
document.getElementById('background')?.classList.add('!hidden');
}
</script>
<template>
<Head title="Welcome" />
<div class="bg-gray-50 text-black/50 dark:bg-black dark:text-white/50">
<img
id="background"
class="absolute -left-20 top-0 max-w-[877px]"
src="https://laravel.com/assets/img/welcome/background.svg"
/>
<div
class="relative flex min-h-screen flex-col items-center justify-center selection:bg-[#FF2D20] selection:text-white"
>
<div class="relative w-full max-w-2xl px-6 lg:max-w-7xl">
<header
class="grid grid-cols-2 items-center gap-2 py-10 lg:grid-cols-3"
>
<div class="flex lg:col-start-2 lg:justify-center">
<svg
class="h-12 w-auto text-white lg:h-16 lg:text-[#FF2D20]"
viewBox="0 0 62 65"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M61.8548 14.6253C61.8778 14.7102 61.8895 14.7978 61.8897 14.8858V28.5615C61.8898 28.737 61.8434 28.9095 61.7554 29.0614C61.6675 29.2132 61.5409 29.3392 61.3887 29.4265L49.9104 36.0351V49.1337C49.9104 49.4902 49.7209 49.8192 49.4118 49.9987L25.4519 63.7916C25.3971 63.8227 25.3372 63.8427 25.2774 63.8639C25.255 63.8714 25.2338 63.8851 25.2101 63.8913C25.0426 63.9354 24.8666 63.9354 24.6991 63.8913C24.6716 63.8838 24.6467 63.8689 24.6205 63.8589C24.5657 63.8389 24.5084 63.8215 24.456 63.7916L0.501061 49.9987C0.348882 49.9113 0.222437 49.7853 0.134469 49.6334C0.0465019 49.4816 0.000120578 49.3092 0 49.1337L0 8.10652C0 8.01678 0.0124642 7.92953 0.0348998 7.84477C0.0423783 7.8161 0.0598282 7.78993 0.0697995 7.76126C0.0884958 7.70891 0.105946 7.65531 0.133367 7.6067C0.152063 7.5743 0.179485 7.54812 0.20192 7.51821C0.230588 7.47832 0.256763 7.43719 0.290416 7.40229C0.319084 7.37362 0.356476 7.35243 0.388883 7.32751C0.425029 7.29759 0.457436 7.26518 0.498568 7.2415L12.4779 0.345059C12.6296 0.257786 12.8015 0.211853 12.9765 0.211853C13.1515 0.211853 13.3234 0.257786 13.475 0.345059L25.4531 7.2415H25.4556C25.4955 7.26643 25.5292 7.29759 25.5653 7.32626C25.5977 7.35119 25.6339 7.37362 25.6625 7.40104C25.6974 7.43719 25.7224 7.47832 25.7523 7.51821C25.7735 7.54812 25.8021 7.5743 25.8196 7.6067C25.8483 7.65656 25.8645 7.70891 25.8844 7.76126C25.8944 7.78993 25.9118 7.8161 25.9193 7.84602C25.9423 7.93096 25.954 8.01853 25.9542 8.10652V33.7317L35.9355 27.9844V14.8846C35.9355 14.7973 35.948 14.7088 35.9704 14.6253C35.9792 14.5954 35.9954 14.5692 36.0053 14.5405C36.0253 14.4882 36.0427 14.4346 36.0702 14.386C36.0888 14.3536 36.1163 14.3274 36.1375 14.2975C36.1674 14.2576 36.1923 14.2165 36.2272 14.1816C36.2559 14.1529 36.292 14.1317 36.3244 14.1068C36.3618 14.0769 36.3942 14.0445 36.4341 14.0208L48.4147 7.12434C48.5663 7.03694 48.7383 6.99094 48.9133 6.99094C49.0883 6.99094 49.2602 7.03694 49.4118 7.12434L61.3899 14.0208C61.4323 14.0457 61.4647 14.0769 61.5021 14.1055C61.5333 14.1305 61.5694 14.1529 61.5981 14.1803C61.633 14.2165 61.6579 14.2576 61.6878 14.2975C61.7103 14.3274 61.7377 14.3536 61.7551 14.386C61.7838 14.4346 61.8 14.4882 61.8199 14.5405C61.8312 14.5692 61.8474 14.5954 61.8548 14.6253ZM59.893 27.9844V16.6121L55.7013 19.0252L49.9104 22.3593V33.7317L59.8942 27.9844H59.893ZM47.9149 48.5566V37.1768L42.2187 40.4299L25.953 49.7133V61.2003L47.9149 48.5566ZM1.99677 9.83281V48.5566L23.9562 61.199V49.7145L12.4841 43.2219L12.4804 43.2194L12.4754 43.2169C12.4368 43.1945 12.4044 43.1621 12.3682 43.1347C12.3371 43.1097 12.3009 43.0898 12.2735 43.0624L12.271 43.0586C12.2386 43.0275 12.2162 42.9888 12.1887 42.9539C12.1638 42.9203 12.1339 42.8916 12.114 42.8567L12.1127 42.853C12.0903 42.8156 12.0766 42.7707 12.0604 42.7283C12.0442 42.6909 12.023 42.656 12.013 42.6161C12.0005 42.5688 11.998 42.5177 11.9931 42.4691C11.9881 42.4317 11.9781 42.3943 11.9781 42.3569V15.5801L6.18848 12.2446L1.99677 9.83281ZM12.9777 2.36177L2.99764 8.10652L12.9752 13.8513L22.9541 8.10527L12.9752 2.36177H12.9777ZM18.1678 38.2138L23.9574 34.8809V9.83281L19.7657 12.2459L13.9749 15.5801V40.6281L18.1678 38.2138ZM48.9133 9.14105L38.9344 14.8858L48.9133 20.6305L58.8909 14.8846L48.9133 9.14105ZM47.9149 22.3593L42.124 19.0252L37.9323 16.6121V27.9844L43.7219 31.3174L47.9149 33.7317V22.3593ZM24.9533 47.987L39.59 39.631L46.9065 35.4555L36.9352 29.7145L25.4544 36.3242L14.9907 42.3482L24.9533 47.987Z"
fill="currentColor"
/>
</svg>
</div>
<nav v-if="canLogin" class="-mx-3 flex flex-1 justify-end">
<Link
v-if="$page.props.auth.user"
:href="route('dashboard')"
class="rounded-md px-3 py-2 text-black ring-1 ring-transparent transition hover:text-black/70 focus:outline-none focus-visible:ring-[#FF2D20] dark:text-white dark:hover:text-white/80 dark:focus-visible:ring-white"
>
Dashboard
</Link>
<template v-else>
<Link
:href="route('login')"
class="rounded-md px-3 py-2 text-black ring-1 ring-transparent transition hover:text-black/70 focus:outline-none focus-visible:ring-[#FF2D20] dark:text-white dark:hover:text-white/80 dark:focus-visible:ring-white"
>
Log in
</Link>
<Link
v-if="canRegister"
:href="route('register')"
class="rounded-md px-3 py-2 text-black ring-1 ring-transparent transition hover:text-black/70 focus:outline-none focus-visible:ring-[#FF2D20] dark:text-white dark:hover:text-white/80 dark:focus-visible:ring-white"
>
Register
</Link>
</template>
</nav>
</header>
<main class="mt-6">
<div class="grid gap-6 lg:grid-cols-2 lg:gap-8">
<a
href="https://laravel.com/docs"
id="docs-card"
class="flex flex-col items-start gap-6 overflow-hidden rounded-lg bg-white p-6 shadow-[0px_14px_34px_0px_rgba(0,0,0,0.08)] ring-1 ring-white/[0.05] transition duration-300 hover:text-black/70 hover:ring-black/20 focus:outline-none focus-visible:ring-[#FF2D20] md:row-span-3 lg:p-10 lg:pb-10 dark:bg-zinc-900 dark:ring-zinc-800 dark:hover:text-white/70 dark:hover:ring-zinc-700 dark:focus-visible:ring-[#FF2D20]"
>
<div
id="screenshot-container"
class="relative flex w-full flex-1 items-stretch"
>
<img
src="https://laravel.com/assets/img/welcome/docs-light.svg"
alt="Laravel documentation screenshot"
class="aspect-video h-full w-full flex-1 rounded-[10px] object-cover object-top drop-shadow-[0px_4px_34px_rgba(0,0,0,0.06)] dark:hidden"
@error="handleImageError"
/>
<img
src="https://laravel.com/assets/img/welcome/docs-dark.svg"
alt="Laravel documentation screenshot"
class="hidden aspect-video h-full w-full flex-1 rounded-[10px] object-cover object-top drop-shadow-[0px_4px_34px_rgba(0,0,0,0.25)] dark:block"
/>
<div
class="absolute -bottom-16 -left-16 h-40 w-[calc(100%+8rem)] bg-gradient-to-b from-transparent via-white to-white dark:via-zinc-900 dark:to-zinc-900"
></div>
</div>
<div
class="relative flex items-center gap-6 lg:items-end"
>
<div
id="docs-card-content"
class="flex items-start gap-6 lg:flex-col"
>
<div
class="flex size-12 shrink-0 items-center justify-center rounded-full bg-[#FF2D20]/10 sm:size-16"
>
<svg
class="size-5 sm:size-6"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<path
fill="#FF2D20"
d="M23 4a1 1 0 0 0-1.447-.894L12.224 7.77a.5.5 0 0 1-.448 0L2.447 3.106A1 1 0 0 0 1 4v13.382a1.99 1.99 0 0 0 1.105 1.79l9.448 4.728c.14.065.293.1.447.1.154-.005.306-.04.447-.105l9.453-4.724a1.99 1.99 0 0 0 1.1-1.789V4ZM3 6.023a.25.25 0 0 1 .362-.223l7.5 3.75a.251.251 0 0 1 .138.223v11.2a.25.25 0 0 1-.362.224l-7.5-3.75a.25.25 0 0 1-.138-.22V6.023Zm18 11.2a.25.25 0 0 1-.138.224l-7.5 3.75a.249.249 0 0 1-.329-.099.249.249 0 0 1-.033-.12V9.772a.251.251 0 0 1 .138-.224l7.5-3.75a.25.25 0 0 1 .362.224v11.2Z"
/>
<path
fill="#FF2D20"
d="m3.55 1.893 8 4.048a1.008 1.008 0 0 0 .9 0l8-4.048a1 1 0 0 0-.9-1.785l-7.322 3.706a.506.506 0 0 1-.452 0L4.454.108a1 1 0 0 0-.9 1.785H3.55Z"
/>
</svg>
</div>
<div class="pt-3 sm:pt-5 lg:pt-0">
<h2
class="text-xl font-semibold text-black dark:text-white"
>
Documentation
</h2>
<p class="mt-4 text-sm/relaxed">
Laravel has wonderful documentation
covering every aspect of the
framework. Whether you are a
newcomer or have prior experience
with Laravel, we recommend reading
our documentation from beginning to
end.
</p>
</div>
</div>
<svg
class="size-6 shrink-0 stroke-[#FF2D20]"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M4.5 12h15m0 0l-6.75-6.75M19.5 12l-6.75 6.75"
/>
</svg>
</div>
</a>
<a
href="https://laracasts.com"
class="flex items-start gap-4 rounded-lg bg-white p-6 shadow-[0px_14px_34px_0px_rgba(0,0,0,0.08)] ring-1 ring-white/[0.05] transition duration-300 hover:text-black/70 hover:ring-black/20 focus:outline-none focus-visible:ring-[#FF2D20] lg:pb-10 dark:bg-zinc-900 dark:ring-zinc-800 dark:hover:text-white/70 dark:hover:ring-zinc-700 dark:focus-visible:ring-[#FF2D20]"
>
<div
class="flex size-12 shrink-0 items-center justify-center rounded-full bg-[#FF2D20]/10 sm:size-16"
>
<svg
class="size-5 sm:size-6"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<g fill="#FF2D20">
<path
d="M24 8.25a.5.5 0 0 0-.5-.5H.5a.5.5 0 0 0-.5.5v12a2.5 2.5 0 0 0 2.5 2.5h19a2.5 2.5 0 0 0 2.5-2.5v-12Zm-7.765 5.868a1.221 1.221 0 0 1 0 2.264l-6.626 2.776A1.153 1.153 0 0 1 8 18.123v-5.746a1.151 1.151 0 0 1 1.609-1.035l6.626 2.776ZM19.564 1.677a.25.25 0 0 0-.177-.427H15.6a.106.106 0 0 0-.072.03l-4.54 4.543a.25.25 0 0 0 .177.427h3.783c.027 0 .054-.01.073-.03l4.543-4.543ZM22.071 1.318a.047.047 0 0 0-.045.013l-4.492 4.492a.249.249 0 0 0 .038.385.25.25 0 0 0 .14.042h5.784a.5.5 0 0 0 .5-.5v-2a2.5 2.5 0 0 0-1.925-2.432ZM13.014 1.677a.25.25 0 0 0-.178-.427H9.101a.106.106 0 0 0-.073.03l-4.54 4.543a.25.25 0 0 0 .177.427H8.4a.106.106 0 0 0 .073-.03l4.54-4.543ZM6.513 1.677a.25.25 0 0 0-.177-.427H2.5A2.5 2.5 0 0 0 0 3.75v2a.5.5 0 0 0 .5.5h1.4a.106.106 0 0 0 .073-.03l4.54-4.543Z"
/>
</g>
</svg>
</div>
<div class="pt-3 sm:pt-5">
<h2
class="text-xl font-semibold text-black dark:text-white"
>
Laracasts
</h2>
<p class="mt-4 text-sm/relaxed">
Laracasts offers thousands of video
tutorials on Laravel, PHP, and JavaScript
development. Check them out, see for
yourself, and massively level up your
development skills in the process.
</p>
</div>
<svg
class="size-6 shrink-0 self-center stroke-[#FF2D20]"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M4.5 12h15m0 0l-6.75-6.75M19.5 12l-6.75 6.75"
/>
</svg>
</a>
<a
href="https://laravel-news.com"
class="flex items-start gap-4 rounded-lg bg-white p-6 shadow-[0px_14px_34px_0px_rgba(0,0,0,0.08)] ring-1 ring-white/[0.05] transition duration-300 hover:text-black/70 hover:ring-black/20 focus:outline-none focus-visible:ring-[#FF2D20] lg:pb-10 dark:bg-zinc-900 dark:ring-zinc-800 dark:hover:text-white/70 dark:hover:ring-zinc-700 dark:focus-visible:ring-[#FF2D20]"
>
<div
class="flex size-12 shrink-0 items-center justify-center rounded-full bg-[#FF2D20]/10 sm:size-16"
>
<svg
class="size-5 sm:size-6"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<g fill="#FF2D20">
<path
d="M8.75 4.5H5.5c-.69 0-1.25.56-1.25 1.25v4.75c0 .69.56 1.25 1.25 1.25h3.25c.69 0 1.25-.56 1.25-1.25V5.75c0-.69-.56-1.25-1.25-1.25Z"
/>
<path
d="M24 10a3 3 0 0 0-3-3h-2V2.5a2 2 0 0 0-2-2H2a2 2 0 0 0-2 2V20a3.5 3.5 0 0 0 3.5 3.5h17A3.5 3.5 0 0 0 24 20V10ZM3.5 21.5A1.5 1.5 0 0 1 2 20V3a.5.5 0 0 1 .5-.5h14a.5.5 0 0 1 .5.5v17c0 .295.037.588.11.874a.5.5 0 0 1-.484.625L3.5 21.5ZM22 20a1.5 1.5 0 1 1-3 0V9.5a.5.5 0 0 1 .5-.5H21a1 1 0 0 1 1 1v10Z"
/>
<path
d="M12.751 6.047h2a.75.75 0 0 1 .75.75v.5a.75.75 0 0 1-.75.75h-2A.75.75 0 0 1 12 7.3v-.5a.75.75 0 0 1 .751-.753ZM12.751 10.047h2a.75.75 0 0 1 .75.75v.5a.75.75 0 0 1-.75.75h-2A.75.75 0 0 1 12 11.3v-.5a.75.75 0 0 1 .751-.753ZM4.751 14.047h10a.75.75 0 0 1 .75.75v.5a.75.75 0 0 1-.75.75h-10A.75.75 0 0 1 4 15.3v-.5a.75.75 0 0 1 .751-.753ZM4.75 18.047h7.5a.75.75 0 0 1 .75.75v.5a.75.75 0 0 1-.75.75h-7.5A.75.75 0 0 1 4 19.3v-.5a.75.75 0 0 1 .75-.753Z"
/>
</g>
</svg>
</div>
<div class="pt-3 sm:pt-5">
<h2
class="text-xl font-semibold text-black dark:text-white"
>
Laravel News
</h2>
<p class="mt-4 text-sm/relaxed">
Laravel News is a community driven portal
and newsletter aggregating all of the latest
and most important news in the Laravel
ecosystem, including new package releases
and tutorials.
</p>
</div>
<svg
class="size-6 shrink-0 self-center stroke-[#FF2D20]"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M4.5 12h15m0 0l-6.75-6.75M19.5 12l-6.75 6.75"
/>
</svg>
</a>
<div
class="flex items-start gap-4 rounded-lg bg-white p-6 shadow-[0px_14px_34px_0px_rgba(0,0,0,0.08)] ring-1 ring-white/[0.05] lg:pb-10 dark:bg-zinc-900 dark:ring-zinc-800"
>
<div
class="flex size-12 shrink-0 items-center justify-center rounded-full bg-[#FF2D20]/10 sm:size-16"
>
<svg
class="size-5 sm:size-6"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<g fill="#FF2D20">
<path
d="M16.597 12.635a.247.247 0 0 0-.08-.237 2.234 2.234 0 0 1-.769-1.68c.001-.195.03-.39.084-.578a.25.25 0 0 0-.09-.267 8.8 8.8 0 0 0-4.826-1.66.25.25 0 0 0-.268.181 2.5 2.5 0 0 1-2.4 1.824.045.045 0 0 0-.045.037 12.255 12.255 0 0 0-.093 3.86.251.251 0 0 0 .208.214c2.22.366 4.367 1.08 6.362 2.118a.252.252 0 0 0 .32-.079 10.09 10.09 0 0 0 1.597-3.733ZM13.616 17.968a.25.25 0 0 0-.063-.407A19.697 19.697 0 0 0 8.91 15.98a.25.25 0 0 0-.287.325c.151.455.334.898.548 1.328.437.827.981 1.594 1.619 2.28a.249.249 0 0 0 .32.044 29.13 29.13 0 0 0 2.506-1.99ZM6.303 14.105a.25.25 0 0 0 .265-.274 13.048 13.048 0 0 1 .205-4.045.062.062 0 0 0-.022-.07 2.5 2.5 0 0 1-.777-.982.25.25 0 0 0-.271-.149 11 11 0 0 0-5.6 2.815.255.255 0 0 0-.075.163c-.008.135-.02.27-.02.406.002.8.084 1.598.246 2.381a.25.25 0 0 0 .303.193 19.924 19.924 0 0 1 5.746-.438ZM9.228 20.914a.25.25 0 0 0 .1-.393 11.53 11.53 0 0 1-1.5-2.22 12.238 12.238 0 0 1-.91-2.465.248.248 0 0 0-.22-.187 18.876 18.876 0 0 0-5.69.33.249.249 0 0 0-.179.336c.838 2.142 2.272 4 4.132 5.353a.254.254 0 0 0 .15.048c1.41-.01 2.807-.282 4.117-.802ZM18.93 12.957l-.005-.008a.25.25 0 0 0-.268-.082 2.21 2.21 0 0 1-.41.081.25.25 0 0 0-.217.2c-.582 2.66-2.127 5.35-5.75 7.843a.248.248 0 0 0-.09.299.25.25 0 0 0 .065.091 28.703 28.703 0 0 0 2.662 2.12.246.246 0 0 0 .209.037c2.579-.701 4.85-2.242 6.456-4.378a.25.25 0 0 0 .048-.189 13.51 13.51 0 0 0-2.7-6.014ZM5.702 7.058a.254.254 0 0 0 .2-.165A2.488 2.488 0 0 1 7.98 5.245a.093.093 0 0 0 .078-.062 19.734 19.734 0 0 1 3.055-4.74.25.25 0 0 0-.21-.41 12.009 12.009 0 0 0-10.4 8.558.25.25 0 0 0 .373.281 12.912 12.912 0 0 1 4.826-1.814ZM10.773 22.052a.25.25 0 0 0-.28-.046c-.758.356-1.55.635-2.365.833a.25.25 0 0 0-.022.48c1.252.43 2.568.65 3.893.65.1 0 .2 0 .3-.008a.25.25 0 0 0 .147-.444c-.526-.424-1.1-.917-1.673-1.465ZM18.744 8.436a.249.249 0 0 0 .15.228 2.246 2.246 0 0 1 1.352 2.054c0 .337-.08.67-.23.972a.25.25 0 0 0 .042.28l.007.009a15.016 15.016 0 0 1 2.52 4.6.25.25 0 0 0 .37.132.25.25 0 0 0 .096-.114c.623-1.464.944-3.039.945-4.63a12.005 12.005 0 0 0-5.78-10.258.25.25 0 0 0-.373.274c.547 2.109.85 4.274.901 6.453ZM9.61 5.38a.25.25 0 0 0 .08.31c.34.24.616.561.8.935a.25.25 0 0 0 .3.127.631.631 0 0 1 .206-.034c2.054.078 4.036.772 5.69 1.991a.251.251 0 0 0 .267.024c.046-.024.093-.047.141-.067a.25.25 0 0 0 .151-.23A29.98 29.98 0 0 0 15.957.764a.25.25 0 0 0-.16-.164 11.924 11.924 0 0 0-2.21-.518.252.252 0 0 0-.215.076A22.456 22.456 0 0 0 9.61 5.38Z"
/>
</g>
</svg>
</div>
<div class="pt-3 sm:pt-5">
<h2
class="text-xl font-semibold text-black dark:text-white"
>
Vibrant Ecosystem
</h2>
<p class="mt-4 text-sm/relaxed">
Laravel's robust library of first-party
tools and libraries, such as
<a
href="https://forge.laravel.com"
class="rounded-sm underline hover:text-black focus:outline-none focus-visible:ring-1 focus-visible:ring-[#FF2D20] dark:hover:text-white dark:focus-visible:ring-[#FF2D20]"
>Forge</a
>,
<a
href="https://vapor.laravel.com"
class="rounded-sm underline hover:text-black focus:outline-none focus-visible:ring-1 focus-visible:ring-[#FF2D20] dark:hover:text-white"
>Vapor</a
>,
<a
href="https://nova.laravel.com"
class="rounded-sm underline hover:text-black focus:outline-none focus-visible:ring-1 focus-visible:ring-[#FF2D20] dark:hover:text-white"
>Nova</a
>,
<a
href="https://envoyer.io"
class="rounded-sm underline hover:text-black focus:outline-none focus-visible:ring-1 focus-visible:ring-[#FF2D20] dark:hover:text-white"
>Envoyer</a
>, and
<a
href="https://herd.laravel.com"
class="rounded-sm underline hover:text-black focus:outline-none focus-visible:ring-1 focus-visible:ring-[#FF2D20] dark:hover:text-white"
>Herd</a
>
help you take your projects to the next
level. Pair them with powerful open source
libraries like
<a
href="https://laravel.com/docs/billing"
class="rounded-sm underline hover:text-black focus:outline-none focus-visible:ring-1 focus-visible:ring-[#FF2D20] dark:hover:text-white"
>Cashier</a
>,
<a
href="https://laravel.com/docs/dusk"
class="rounded-sm underline hover:text-black focus:outline-none focus-visible:ring-1 focus-visible:ring-[#FF2D20] dark:hover:text-white"
>Dusk</a
>,
<a
href="https://laravel.com/docs/broadcasting"
class="rounded-sm underline hover:text-black focus:outline-none focus-visible:ring-1 focus-visible:ring-[#FF2D20] dark:hover:text-white"
>Echo</a
>,
<a
href="https://laravel.com/docs/horizon"
class="rounded-sm underline hover:text-black focus:outline-none focus-visible:ring-1 focus-visible:ring-[#FF2D20] dark:hover:text-white"
>Horizon</a
>,
<a
href="https://laravel.com/docs/sanctum"
class="rounded-sm underline hover:text-black focus:outline-none focus-visible:ring-1 focus-visible:ring-[#FF2D20] dark:hover:text-white"
>Sanctum</a
>,
<a
href="https://laravel.com/docs/telescope"
class="rounded-sm underline hover:text-black focus:outline-none focus-visible:ring-1 focus-visible:ring-[#FF2D20] dark:hover:text-white"
>Telescope</a
>, and more.
</p>
</div>
</div>
</div>
</main>
<footer
class="py-16 text-center text-sm text-black dark:text-white/70"
>
Laravel v{{ laravelVersion }} (PHP v{{ phpVersion }})
</footer>
</div>
</div>
</div>
</template>

View file

@ -0,0 +1,13 @@
Hallo,
für den Gottesdienst "{{ $service->title }}" am {{ $service->date }} wird folgender Song benötigt:
Song: {{ $songName }}
CCLI-ID: {{ $ccliId }}
Bitte erstelle diesen Song in der Song-Datenbank.
Link zum Gottesdienst: {{ url('/services/' . $service->id . '/edit') }}
Viele Grüße
{{ config('app.name') }}

View file

@ -1,14 +1,43 @@
<?php
use Illuminate\Foundation\Application;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\SyncController;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
Route::get('/', function () {
return Inertia::render('Welcome', [
'canLogin' => Route::has('login'),
'canRegister' => Route::has('register'),
'laravelVersion' => Application::VERSION,
'phpVersion' => PHP_VERSION,
]);
/*
|--------------------------------------------------------------------------
| Authentifizierung (öffentlich)
|--------------------------------------------------------------------------
*/
Route::middleware('guest')->group(function () {
Route::get('/login', [AuthController::class, 'showLogin'])->name('login');
Route::get('/auth/churchtools', [AuthController::class, 'redirect'])->name('auth.churchtools');
Route::get('/auth/churchtools/callback', [AuthController::class, 'callback'])->name('auth.churchtools.callback');
});
/*
|--------------------------------------------------------------------------
| Abmeldung
|--------------------------------------------------------------------------
*/
Route::post('/logout', [AuthController::class, 'logout'])
->middleware('auth')
->name('logout');
/*
|--------------------------------------------------------------------------
| Geschützte Routen (nur für angemeldete Benutzer)
|--------------------------------------------------------------------------
*/
Route::middleware('auth')->group(function () {
Route::get('/', function () {
return redirect()->route('dashboard');
});
Route::get('/dashboard', function () {
return Inertia::render('Dashboard');
})->name('dashboard');
Route::post('/sync', [SyncController::class, 'sync'])->name('sync');
});

View file

@ -0,0 +1,97 @@
<?php
namespace App\Cts;
use CTApi\CTClient;
use CTApi\CTConfig;
use CTApi\Models\Events\Event\EventRequest;
use CTApi\Models\Events\Song\Song;
use CTApi\Utils\CTResponseUtil;
use Throwable;
final class CtsApiSpikeSync
{
public static function run(
string $apiUrl,
string $apiToken,
string $fromDate,
int $songId,
?CTClient $client = null,
): array {
if (trim($apiToken) === '') {
return [
'auth' => [
'ok' => false,
'method' => 'none',
'blocker' => 'CTS_API_TOKEN fehlt; Authentifizierung nicht moeglich.',
],
'events' => ['count' => 0, 'first' => null],
'song' => ['hasCcli' => false, 'hasLyrics' => false, 'arrangements_count' => 0],
];
}
CTConfig::clearConfig();
CTConfig::setApiUrl(rtrim($apiUrl, '/'));
$legacyApiKeySetter = 'setApiKey';
$authMethod = 'raw-http-authorization-header';
if (method_exists(CTConfig::class, $legacyApiKeySetter)) {
CTConfig::{$legacyApiKeySetter}($apiToken);
$authMethod = 'setApiKey';
} elseif (method_exists(CTConfig::class, 'authWithLoginToken')) {
CTConfig::authWithLoginToken($apiToken);
$authMethod = 'authWithLoginToken';
}
if ($client !== null) {
CTClient::setClient($client);
}
try {
$events = EventRequest::where('from', $fromDate)->get();
$songResponse = CTClient::getClient()->get('/api/songs/' . $songId);
$songRaw = CTResponseUtil::dataAsArray($songResponse);
$song = Song::createModelFromData($songRaw);
} catch (Throwable $throwable) {
return [
'auth' => [
'ok' => false,
'method' => $authMethod,
'blocker' => $throwable->getMessage(),
],
'events' => ['count' => 0, 'first' => null],
'song' => ['hasCcli' => false, 'hasLyrics' => false, 'arrangements_count' => 0],
];
}
$firstEvent = $events[0] ?? null;
return [
'auth' => [
'ok' => true,
'method' => $authMethod,
'blocker' => null,
],
'events' => [
'count' => count($events),
'first' => $firstEvent === null ? null : [
'id' => $firstEvent->getId(),
'title' => $firstEvent->getName(),
'start_date' => $firstEvent->getStartDate(),
'note' => $firstEvent->getNote(),
],
],
'song' => [
'hasCcli' => $song !== null && trim((string) $song->getCcli()) !== '',
'ccli' => $song?->getCcli(),
'hasLyrics' => array_key_exists('lyrics', $songRaw),
'lyrics_type' => is_array($songRaw['lyrics'] ?? null) ? ($songRaw['lyrics']['type'] ?? null) : null,
'arrangements_count' => $song === null ? 0 : count($song->getArrangements()),
],
'raw_shapes' => [
'song_keys' => array_keys($songRaw),
],
];
}
}

View file

@ -0,0 +1,237 @@
<?php
use App\Services\ChurchToolsService;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
beforeEach(function () {
ensureSyncTables();
});
test('cts:sync synchronisiert services, agenda songs und schreibt sync log', function () {
Carbon::setTestNow('2026-03-01 09:00:00');
$localSongId = DB::table('songs')->insertGetId([
'title' => 'Way Maker',
'ccli_id' => '7115744',
'created_at' => now(),
'updated_at' => now(),
]);
app()->instance(ChurchToolsService::class, new ChurchToolsService(
eventFetcher: fn () => [
new FakeEvent(
id: 100,
title: 'Gottesdienst Sonntag',
startDate: '2026-03-08T10:00:00+00:00',
note: 'Probe',
eventServices: [
new FakeEventService('Predigt', new FakePerson('Max', 'Mustermann')),
new FakeEventService('Beamer', new FakePerson('Lisa', 'Technik')),
],
),
],
songFetcher: fn () => [new FakeSong(id: 1, title: 'Way Maker', ccli: '7115744')],
agendaFetcher: fn () => new FakeAgenda([
new FakeSong(id: 5001, title: 'Way Maker', ccli: '7115744'),
new FakeSong(id: 5002, title: 'Unbekannt', ccli: '9999999'),
]),
eventServiceFetcher: fn (int $eventId) => [
new FakeEventService('Predigt', new FakePerson('Max', 'Mustermann')),
new FakeEventService('Beamer', new FakePerson('Lisa', 'Technik')),
],
));
Artisan::call('cts:sync');
expect(Artisan::output())->toContain('Daten wurden aktualisiert');
$service = DB::table('services')->where('cts_event_id', '100')->first();
expect($service)->not->toBeNull();
expect($service->title)->toBe('Gottesdienst Sonntag');
expect($service->preacher_name)->toBe('Max Mustermann');
expect($service->beamer_tech_name)->toBe('Lisa Technik');
$matchedSong = DB::table('service_songs')->where('order', 1)->first();
expect($matchedSong)->not->toBeNull();
expect((int) $matchedSong->song_id)->toBe($localSongId);
expect($matchedSong->matched_at)->not->toBeNull();
$unmatchedSong = DB::table('service_songs')->where('order', 2)->first();
expect($unmatchedSong)->not->toBeNull();
expect($unmatchedSong->song_id)->toBeNull();
expect($unmatchedSong->cts_ccli_id)->toBe('9999999');
$syncLog = DB::table('cts_sync_log')->latest('id')->first();
expect($syncLog)->not->toBeNull();
expect($syncLog->status)->toBe('success');
expect((int) $syncLog->events_count)->toBe(1);
expect((int) $syncLog->songs_count)->toBe(2);
});
function ensureSyncTables(): void
{
if (! Schema::hasTable('services')) {
Schema::create('services', function (Blueprint $table) {
$table->id();
$table->string('cts_event_id')->unique();
$table->string('title');
$table->date('date')->nullable();
$table->string('preacher_name')->nullable();
$table->string('beamer_tech_name')->nullable();
$table->timestamp('last_synced_at')->nullable();
$table->json('cts_data')->nullable();
$table->timestamps();
});
}
if (! Schema::hasTable('songs')) {
Schema::create('songs', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('ccli_id')->nullable()->unique();
$table->timestamps();
});
}
if (! Schema::hasTable('service_songs')) {
Schema::create('service_songs', function (Blueprint $table) {
$table->id();
$table->foreignId('service_id')->constrained('services')->cascadeOnDelete();
$table->foreignId('song_id')->nullable()->constrained('songs')->nullOnDelete();
$table->string('cts_song_name');
$table->string('cts_ccli_id')->nullable();
$table->unsignedInteger('order')->default(0);
$table->timestamp('matched_at')->nullable();
$table->timestamps();
$table->unique(['service_id', 'order']);
});
}
if (! Schema::hasTable('cts_sync_log')) {
Schema::create('cts_sync_log', function (Blueprint $table) {
$table->id();
$table->timestamp('synced_at')->nullable();
$table->unsignedInteger('events_count')->default(0);
$table->unsignedInteger('songs_count')->default(0);
$table->string('status');
$table->text('error')->nullable();
$table->timestamps();
});
}
}
final class FakeEvent
{
public function __construct(
private readonly int $id,
private readonly string $title,
private readonly string $startDate,
private readonly ?string $note = null,
private readonly array $eventServices = [],
) {
}
public function getId(): string
{
return (string) $this->id;
}
public function getName(): string
{
return $this->title;
}
public function getStartDate(): string
{
return $this->startDate;
}
public function getNote(): ?string
{
return $this->note;
}
public function getEventServices(): array
{
return $this->eventServices;
}
}
final class FakeEventService
{
public function __construct(
private readonly string $name,
private readonly ?FakePerson $person,
) {
}
public function getName(): string
{
return $this->name;
}
public function getPerson(): ?FakePerson
{
return $this->person;
}
}
final class FakePerson
{
public function __construct(
private readonly string $firstName,
private readonly string $lastName,
) {
}
public function getFirstName(): string
{
return $this->firstName;
}
public function getLastName(): string
{
return $this->lastName;
}
}
final class FakeAgenda
{
public function __construct(private readonly array $songs)
{
}
public function getSongs(): array
{
return $this->songs;
}
}
final class FakeSong
{
public function __construct(
private readonly int $id,
private readonly string $title,
private readonly ?string $ccli,
) {
}
public function getId(): string
{
return (string) $this->id;
}
public function getName(): string
{
return $this->title;
}
public function getCcli(): ?string
{
return $this->ccli;
}
}

View file

@ -0,0 +1,63 @@
<?php
use App\Models\CtsSyncLog;
use App\Models\Service;
use App\Models\ServiceSong;
use App\Models\Slide;
use App\Models\Song;
use App\Models\SongArrangement;
use App\Models\SongArrangementGroup;
use App\Models\SongGroup;
use App\Models\SongSlide;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Schema;
uses(RefreshDatabase::class);
test('all expected database tables exist', function () {
$expectedTables = [
'users',
'password_reset_tokens',
'sessions',
'cache',
'cache_locks',
'jobs',
'job_batches',
'failed_jobs',
'services',
'songs',
'song_groups',
'song_slides',
'song_arrangements',
'song_arrangement_groups',
'service_songs',
'slides',
'cts_sync_log',
];
foreach ($expectedTables as $table) {
expect(Schema::hasTable($table))->toBeTrue("Table [{$table}] should exist.");
}
});
test('all factories create valid records', function () {
Service::factory()->create();
Song::factory()->create();
SongGroup::factory()->create();
SongSlide::factory()->create();
SongArrangement::factory()->create();
SongArrangementGroup::factory()->create();
ServiceSong::factory()->create();
Slide::factory()->create();
CtsSyncLog::factory()->create();
expect(Service::count())->toBeGreaterThan(0)
->and(Song::count())->toBeGreaterThan(0)
->and(SongGroup::count())->toBeGreaterThan(0)
->and(SongSlide::count())->toBeGreaterThan(0)
->and(SongArrangement::count())->toBeGreaterThan(0)
->and(SongArrangementGroup::count())->toBeGreaterThan(0)
->and(ServiceSong::count())->toBeGreaterThan(0)
->and(Slide::count())->toBeGreaterThan(0)
->and(CtsSyncLog::count())->toBeGreaterThan(0);
});

View file

@ -0,0 +1,86 @@
<?php
use App\Services\FileConversionService;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
beforeEach(function () {
Storage::fake('public');
});
test('convert image creates 1920x1080 jpg with black bars and thumbnail', function () {
$service = app(FileConversionService::class);
$file = makePngUpload('landscape.png', 400, 300);
$result = $service->convertImage($file);
expect($result)->toHaveKeys(['filename', 'thumbnail']);
expect($result['filename'])->toStartWith('slides/')->toEndWith('.jpg');
expect($result['thumbnail'])->toStartWith('slides/thumbnails/')->toEndWith('.jpg');
expect(Storage::disk('public')->exists($result['filename']))->toBeTrue();
expect(Storage::disk('public')->exists($result['thumbnail']))->toBeTrue();
$mainPath = Storage::disk('public')->path($result['filename']);
[$width, $height] = getimagesize($mainPath);
expect($width)->toBe(1920);
expect($height)->toBe(1080);
$image = imagecreatefromjpeg($mainPath);
expect($image)->not->toBeFalse();
$corner = imagecolorsforindex($image, imagecolorat($image, 0, 0));
$center = imagecolorsforindex($image, imagecolorat($image, 960, 540));
expect($corner['red'] + $corner['green'] + $corner['blue'])->toBeLessThan(20);
expect($center['red'])->toBeGreaterThan(100);
$thumbPath = Storage::disk('public')->path($result['thumbnail']);
[$thumbWidth, $thumbHeight] = getimagesize($thumbPath);
expect($thumbWidth)->toBe(320);
expect($thumbHeight)->toBe(180);
});
test('portrait image gets pillarbox bars on left and right', function () {
$service = app(FileConversionService::class);
$file = makePngUpload('portrait.png', 1080, 1920);
$result = $service->convertImage($file);
$mainPath = Storage::disk('public')->path($result['filename']);
[$width, $height] = getimagesize($mainPath);
expect($width)->toBe(1920);
expect($height)->toBe(1080);
$image = imagecreatefromjpeg($mainPath);
expect($image)->not->toBeFalse();
$left = imagecolorsforindex($image, imagecolorat($image, 10, 540));
$right = imagecolorsforindex($image, imagecolorat($image, 1910, 540));
$center = imagecolorsforindex($image, imagecolorat($image, 960, 540));
expect($left['red'] + $left['green'] + $left['blue'])->toBeLessThan(20);
expect($right['red'] + $right['green'] + $right['blue'])->toBeLessThan(20);
expect($center['red'])->toBeGreaterThan(100);
});
function makePngUpload(string $name, int $width, int $height): UploadedFile
{
$path = tempnam(sys_get_temp_dir(), 'cts-img-');
if ($path === false) {
throw new RuntimeException('Temp-Datei konnte nicht erstellt werden.');
}
$image = imagecreatetruecolor($width, $height);
if ($image === false) {
throw new RuntimeException('Bild konnte nicht erstellt werden.');
}
$red = imagecolorallocate($image, 255, 0, 0);
imagefill($image, 0, 0, $red);
imagepng($image, $path);
return new UploadedFile($path, $name, 'image/png', null, true);
}

View file

@ -1,7 +1,17 @@
<?php
test('home route returns 200', function () {
use App\Models\User;
test('home route redirects unauthenticated users to login', function () {
$response = $this->get('/');
$response->assertStatus(200);
$response->assertRedirect('/login');
});
test('home route redirects authenticated users to dashboard', function () {
$user = User::factory()->create();
$response = $this->actingAs($user)->get('/');
$response->assertRedirect(route('dashboard'));
});

View file

@ -0,0 +1,72 @@
<?php
namespace Tests\Feature;
use App\Mail\MissingSongRequest;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Route;
use Tests\TestCase;
class MissingSongMailTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
// Register a test route for services.edit
Route::get('/services/{id}/edit', function ($id) {
return "Service {$id}";
})->name('services.edit');
}
public function test_missing_song_request_mailable_renders_with_german_content(): void
{
$songName = 'Großer Gott';
$ccliId = '12345678';
$serviceId = 1;
$serviceTitle = 'Sonntagsgottesdienst';
$serviceDate = '2026-03-08';
// Create a mock service object
$service = new \stdClass();
$service->id = $serviceId;
$service->title = $serviceTitle;
$service->date = $serviceDate;
$mailable = new MissingSongRequest($songName, $ccliId, $service);
// Assert the mailable renders without errors
$rendered = $mailable->render();
$subject = $mailable->build()->subject;
$rendered = $mailable->render();
// Check that the rendered content contains German text
$this->assertStringContainsString('Song-Anfrage', $subject);
$this->assertStringContainsString($songName, $rendered);
$this->assertStringContainsString($ccliId, $rendered);
$this->assertStringContainsString($serviceTitle, $rendered);
$this->assertStringContainsString('wird folgender Song benötigt', $rendered);
$this->assertStringContainsString('Bitte erstelle diesen Song', $rendered);
$this->assertStringContainsString('/services/1/edit', $rendered);
}
public function test_missing_song_request_mailable_has_correct_subject(): void
{
$songName = 'Großer Gott';
$ccliId = '12345678';
$service = new \stdClass();
$service->id = 1;
$service->title = 'Sonntagsgottesdienst';
$service->date = '2026-03-08';
$mailable = new MissingSongRequest($songName, $ccliId, $service);
// Get the subject from the mailable
$subject = $mailable->build()->subject;
$this->assertStringContainsString('Song-Anfrage', $subject);
$this->assertStringContainsString($songName, $subject);
$this->assertStringContainsString($ccliId, $subject);
}
}

167
tests/Feature/OAuthTest.php Normal file
View file

@ -0,0 +1,167 @@
<?php
use App\Models\User;
use Laravel\Socialite\Facades\Socialite;
use Laravel\Socialite\Two\User as SocialiteUser;
it('redirects unauthenticated users to login', function () {
$response = $this->get('/');
$response->assertRedirect('/login');
});
it('shows login page with OAuth button', function () {
$response = $this->get('/login');
$response->assertStatus(200);
$response->assertInertia(
fn ($page) => $page
->component('Auth/Login')
);
});
it('login page has no email or password inputs', function () {
$response = $this->get('/login');
$response->assertStatus(200);
// The Login.vue should NOT contain email/password form fields
// This is verified by checking the component renders correctly
$response->assertInertia(
fn ($page) => $page
->component('Auth/Login')
);
});
it('redirects to ChurchTools OAuth on auth initiation', function () {
$providerMock = Mockery::mock(\Laravel\Socialite\Two\AbstractProvider::class);
$providerMock->shouldReceive('redirect')
->once()
->andReturn(redirect('https://churchtools.example.com/oauth/authorize'));
Socialite::shouldReceive('driver')
->with('churchtools')
->once()
->andReturn($providerMock);
$response = $this->get('/auth/churchtools');
$response->assertRedirect();
$response->assertRedirectContains('churchtools.example.com/oauth/authorize');
});
it('creates a new user from OAuth callback', function () {
$socialiteUser = new SocialiteUser();
$socialiteUser->map([
'id' => '42',
'name' => 'Max Mustermann',
'email' => 'max@example.com',
'avatar' => 'https://churchtools.example.com/avatar/42.jpg',
]);
$socialiteUser->user = [
'id' => 42,
'firstName' => 'Max',
'lastName' => 'Mustermann',
'displayName' => 'Max Mustermann',
'email' => 'max@example.com',
'imageUrl' => 'https://churchtools.example.com/avatar/42.jpg',
'groups' => [['id' => 1, 'name' => 'Worship']],
'roles' => [['id' => 2, 'name' => 'Admin']],
];
$providerMock = Mockery::mock(\Laravel\Socialite\Two\AbstractProvider::class);
$providerMock->shouldReceive('user')
->once()
->andReturn($socialiteUser);
Socialite::shouldReceive('driver')
->with('churchtools')
->once()
->andReturn($providerMock);
$response = $this->get('/auth/churchtools/callback');
$response->assertRedirect(route('dashboard'));
$this->assertDatabaseHas('users', [
'email' => 'max@example.com',
'name' => 'Max Mustermann',
'churchtools_id' => 42,
'avatar' => 'https://churchtools.example.com/avatar/42.jpg',
]);
$user = User::where('email', 'max@example.com')->first();
expect($user)->not->toBeNull();
expect((int) $user->churchtools_id)->toBe(42);
expect($user->churchtools_groups)->toBe([['id' => 1, 'name' => 'Worship']]);
expect($user->churchtools_roles)->toBe([['id' => 2, 'name' => 'Admin']]);
$this->assertAuthenticatedAs($user);
});
it('updates existing user on OAuth callback', function () {
$existingUser = User::factory()->create([
'email' => 'max@example.com',
'name' => 'Old Name',
'churchtools_id' => 42,
]);
$socialiteUser = new SocialiteUser();
$socialiteUser->map([
'id' => '42',
'name' => 'Max Mustermann',
'email' => 'max@example.com',
'avatar' => 'https://churchtools.example.com/avatar/42.jpg',
]);
$socialiteUser->user = [
'id' => 42,
'firstName' => 'Max',
'lastName' => 'Mustermann',
'displayName' => 'Max Mustermann',
'email' => 'max@example.com',
'imageUrl' => 'https://churchtools.example.com/avatar/42.jpg',
'groups' => [['id' => 1, 'name' => 'Worship']],
'roles' => [['id' => 2, 'name' => 'Admin']],
];
$providerMock = Mockery::mock(\Laravel\Socialite\Two\AbstractProvider::class);
$providerMock->shouldReceive('user')
->once()
->andReturn($socialiteUser);
Socialite::shouldReceive('driver')
->with('churchtools')
->once()
->andReturn($providerMock);
$response = $this->get('/auth/churchtools/callback');
$response->assertRedirect(route('dashboard'));
$existingUser->refresh();
expect($existingUser->name)->toBe('Max Mustermann');
expect($existingUser->avatar)->toBe('https://churchtools.example.com/avatar/42.jpg');
expect(User::count())->toBe(1);
$this->assertAuthenticatedAs($existingUser);
});
it('logs out user and redirects to login', function () {
$user = User::factory()->create();
$response = $this->actingAs($user)->post('/logout');
$response->assertRedirect('/login');
$this->assertGuest();
});
it('does not have register routes', function () {
$response = $this->get('/register');
$response->assertStatus(404);
});
it('authenticated user can access dashboard', function () {
$user = User::factory()->create();
$response = $this->actingAs($user)->get('/dashboard');
$response->assertStatus(200);
});

View file

@ -0,0 +1,120 @@
<?php
use App\Models\CtsSyncLog;
use App\Models\User;
test('shared props include auth user with expected fields when authenticated', function () {
$user = User::factory()->create([
'name' => 'Max Mustermann',
'email' => 'max@example.de',
'avatar' => 'https://example.de/avatar.jpg',
]);
$response = $this->actingAs($user)->get('/dashboard');
$response->assertOk();
$response->assertInertia(
fn ($page) => $page
->has('auth.user')
->where('auth.user.id', $user->id)
->where('auth.user.name', 'Max Mustermann')
->where('auth.user.email', 'max@example.de')
->where('auth.user.avatar', 'https://example.de/avatar.jpg')
->missing('auth.user.password')
->missing('auth.user.remember_token')
);
});
test('shared props include null auth user when not logged in', function () {
// Guest accessing /login should get Inertia response with null auth user
$response = $this->get('/login');
$response->assertOk();
$response->assertInertia(
fn ($page) => $page
->where('auth.user', null)
);
});
test('shared props include flash success message', function () {
$user = User::factory()->create();
$response = $this->actingAs($user)
->withSession(['success' => 'Erfolgreich gespeichert!'])
->get('/dashboard');
$response->assertOk();
$response->assertInertia(
fn ($page) => $page
->has('flash')
->where('flash.success', 'Erfolgreich gespeichert!')
);
});
test('shared props include flash error message', function () {
$user = User::factory()->create();
$response = $this->actingAs($user)
->withSession(['error' => 'Ein Fehler ist aufgetreten.'])
->get('/dashboard');
$response->assertOk();
$response->assertInertia(
fn ($page) => $page
->has('flash')
->where('flash.error', 'Ein Fehler ist aufgetreten.')
);
});
test('shared props include last_synced_at from latest sync log', function () {
$user = User::factory()->create();
$syncTime = now()->subMinutes(5)->startOfSecond();
CtsSyncLog::create([
'synced_at' => $syncTime,
'events_count' => 10,
'songs_count' => 5,
'status' => 'success',
]);
// Create an older one to confirm "latest" is used
CtsSyncLog::create([
'synced_at' => now()->subHours(2),
'events_count' => 8,
'songs_count' => 3,
'status' => 'success',
]);
$response = $this->actingAs($user)->get('/dashboard');
$response->assertOk();
$response->assertInertia(
fn ($page) => $page
->has('last_synced_at')
->where('last_synced_at', $syncTime->toJSON())
);
});
test('shared props include null last_synced_at when no sync log exists', function () {
$user = User::factory()->create();
$response = $this->actingAs($user)->get('/dashboard');
$response->assertOk();
$response->assertInertia(
fn ($page) => $page
->where('last_synced_at', null)
);
});
test('shared props include app_name from config', function () {
$user = User::factory()->create();
$response = $this->actingAs($user)->get('/dashboard');
$response->assertOk();
$response->assertInertia(
fn ($page) => $page
->has('app_name')
);
});