diff --git a/_ide_helper_models.php b/_ide_helper_models.php index 00780f05..7a3839ce 100644 --- a/_ide_helper_models.php +++ b/_ide_helper_models.php @@ -344,6 +344,9 @@ class IdeHelperSeat {} * @property int $order * @property int $revision * @property string|null $image_url + * @property string|null $image_height + * @property string|null $image_width + * @property int $scale * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at * @property-read \App\Models\Event $event diff --git a/app/Http/Controllers/Admin/SeatingPlanController.php b/app/Http/Controllers/Admin/SeatingPlanController.php index 5c1cd6b4..b94dc732 100644 --- a/app/Http/Controllers/Admin/SeatingPlanController.php +++ b/app/Http/Controllers/Admin/SeatingPlanController.php @@ -35,6 +35,9 @@ protected function updateObject(SeatingPlan $plan, Request $request) { $plan->name = $request->input('name'); $plan->image_url = $request->input('image_url'); + $plan->image_height = getimagesize($request->input('image_url'))[1]; + $plan->image_width = getimagesize($request->input('image_url'))[0]; + $plan->scale = $request->input('scale') ? $request->input('scale') : 100; $plan->save(); } diff --git a/app/Http/Requests/Admin/SeatingPlanUpdateRequest.php b/app/Http/Requests/Admin/SeatingPlanUpdateRequest.php index bfbcc2f2..305dc737 100644 --- a/app/Http/Requests/Admin/SeatingPlanUpdateRequest.php +++ b/app/Http/Requests/Admin/SeatingPlanUpdateRequest.php @@ -38,6 +38,7 @@ function (string $attribute, mixed $value, Closure $fail) { }, ], 'image_url' => 'sometimes|url:http,https|nullable', + 'scale' => 'sometimes|integer|numeric|min:25|max:200|nullable', ]; } } diff --git a/database/migrations/2024_09_04_154938_add_scale_and_sizing_to_seating_plans.php b/database/migrations/2024_09_04_154938_add_scale_and_sizing_to_seating_plans.php new file mode 100644 index 00000000..d23ad7f9 --- /dev/null +++ b/database/migrations/2024_09_04_154938_add_scale_and_sizing_to_seating_plans.php @@ -0,0 +1,42 @@ +integer('scale')->default(100)->after('order'); + $table->integer('image_height')->after('image_url')->nullable(); + $table->integer('image_width')->after('image_height')->nullable(); + }); + + foreach (SeatingPlan::all() as $plan) { + if ($plan->image_url) + { + $plan->image_height = getimagesize($plan->image_url)[1]; + $plan->image_width = getimagesize($plan->image_url)[0]; + $plan->save(); + } + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('seating_plans', function (Blueprint $table) { + $table->dropColumn('scale'); + $table->dropColumn('image_height'); + $table->dropColumn('image_width'); + }); + } +}; diff --git a/resources/views/admin/events/seats.blade.php b/resources/views/admin/events/seats.blade.php index 97eeaf31..8fb11c0c 100644 --- a/resources/views/admin/events/seats.blade.php +++ b/resources/views/admin/events/seats.blade.php @@ -125,10 +125,13 @@ class="badge bg-muted text-muted-fg">{{ $clanMember->clan->name }} style="min-width: {{ collect($seats[$plan->id] ?? [])->max('x') * 2 + 4 }}em;">
{{ $message }}
+ @enderror +