APP als Hybrid Version - Anbindung an API

This commit is contained in:
Kevin Adametz 2026-06-05 09:54:12 +02:00
parent d054732bf5
commit c1514999be
46 changed files with 3418 additions and 196 deletions

View file

@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use App\Models\Event;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\EventMedia>
*/
class EventMediaFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$user = User::factory();
return [
'uuid' => (string) Str::uuid(),
'user_id' => $user,
'event_id' => Event::factory()->for($user),
'collection' => 'gallery',
'name' => fake()->word().'.jpg',
'mime_type' => 'image/jpeg',
'disk' => 'local',
'path' => 'event-media/test/original.jpg',
'thumbnail_path' => 'event-media/test/thumb.jpg',
'preview_path' => 'event-media/test/preview.jpg',
'size' => 12345,
'width' => 1200,
'height' => 800,
'thumbnail_width' => 320,
'thumbnail_height' => 320,
'preview_width' => 900,
'preview_height' => 600,
];
}
}

View file

@ -0,0 +1,33 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\UserSetting>
*/
class UserSettingFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'user_id' => User::factory(),
'settings' => [
'appearance' => 'system',
'accentColor' => 'base',
'language' => 'de',
'timelineZoom' => 1,
'timelineScrollLeft' => null,
'presets' => [],
'activePresetId' => null,
],
];
}
}

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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('user_settings', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->unique()->constrained()->cascadeOnDelete();
$table->json('settings');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_settings');
}
};

View file

@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('event_media', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('event_id')->constrained()->cascadeOnDelete();
$table->string('collection')->default('gallery');
$table->string('name');
$table->string('mime_type');
$table->string('disk')->default('local');
$table->string('path');
$table->string('thumbnail_path');
$table->string('preview_path')->nullable();
$table->unsignedBigInteger('size');
$table->unsignedInteger('width')->nullable();
$table->unsignedInteger('height')->nullable();
$table->unsignedInteger('thumbnail_width')->nullable();
$table->unsignedInteger('thumbnail_height')->nullable();
$table->unsignedInteger('preview_width')->nullable();
$table->unsignedInteger('preview_height')->nullable();
$table->timestamps();
$table->index(['user_id', 'event_id']);
$table->index(['event_id', 'collection']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('event_media');
}
};

View file

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('event_media', function (Blueprint $table) {
if (! Schema::hasColumn('event_media', 'preview_path')) {
$table->string('preview_path')->nullable()->after('thumbnail_path');
}
if (! Schema::hasColumn('event_media', 'preview_width')) {
$table->unsignedInteger('preview_width')->nullable()->after('thumbnail_height');
}
if (! Schema::hasColumn('event_media', 'preview_height')) {
$table->unsignedInteger('preview_height')->nullable()->after('preview_width');
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('event_media', function (Blueprint $table) {
$columns = array_filter([
Schema::hasColumn('event_media', 'preview_path') ? 'preview_path' : null,
Schema::hasColumn('event_media', 'preview_width') ? 'preview_width' : null,
Schema::hasColumn('event_media', 'preview_height') ? 'preview_height' : null,
]);
if ($columns !== []) {
$table->dropColumn($columns);
}
});
}
};

View file

@ -3,8 +3,9 @@
namespace Database\Seeders;
use App\Models\User;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Laravel\Passport\Client;
use Laravel\Passport\ClientRepository;
class DatabaseSeeder extends Seeder
{
@ -13,11 +14,37 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// User::factory(10)->create();
User::query()->updateOrCreate(
['email' => 'test@example.com'],
[
'name' => 'Test User',
'email_verified_at' => now(),
'password' => 'password',
],
);
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
]);
foreach (range(1, 6) as $number) {
User::query()->updateOrCreate(
['email' => "user{$number}@thats-me.app"],
[
'name' => "User {$number}",
'email_verified_at' => now(),
'password' => 'pass',
],
);
}
$hasPersonalAccessClient = Client::query()
->where('provider', 'users')
->where('revoked', false)
->get()
->contains(fn (Client $client): bool => $client->hasGrantType('personal_access'));
if (! $hasPersonalAccessClient) {
app(ClientRepository::class)->createPersonalAccessGrantClient(
'Thats Me Quasar Personal Access Client',
'users',
);
}
}
}