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;">
image_url) + background-image:url('{{ $plan->image_url }}'); + min-height: {{ $plan->image_height}}px; + min-width: {{ $plan->image_width}}px"; + @else + min-height: {{ (collect($seats[$plan->id] ?? [])->max('y') * 2) + 4 }}em;" + @endif > @foreach($seats[$plan->id] as $seat) @php @@ -168,7 +171,7 @@ class="badge bg-muted text-muted-fg">{{ $clanMember->clan->name }} @if($link) href="{{ $link }}" @endif - style="left: {{ $seat->x * 2 }}em; top: {{ $seat->y * 2 }}em;" + style="left: {{ $seat->x * 0.02 * $plan->scale }}em; top: {{ $seat->y * 0.02 * $plan->scale }}em; width: {{ 0.019 * $plan->scale }}em; height: {{ 0.019 * $plan->scale }}em;" data-bs-trigger="hover" data-bs-toggle="popover" data-bs-placement="right" data-bs-html="true" title="{{ $seat->description }} {{ $seat->label }}" diff --git a/resources/views/admin/seatingplans/_form.blade.php b/resources/views/admin/seatingplans/_form.blade.php index c9e0e162..93d91ee8 100644 --- a/resources/views/admin/seatingplans/_form.blade.php +++ b/resources/views/admin/seatingplans/_form.blade.php @@ -22,4 +22,20 @@ @enderror
+
+ +
+
+ +
+
%
+
+
+ The scale of the seating plan grid, expressed as a percentile. Valid range is 25-200. + @error('scale') +

{{ $message }}

+ @enderror +
+
diff --git a/resources/views/admin/seatingplans/show.blade.php b/resources/views/admin/seatingplans/show.blade.php index 29e9360c..83ba6aa6 100644 --- a/resources/views/admin/seatingplans/show.blade.php +++ b/resources/views/admin/seatingplans/show.blade.php @@ -58,6 +58,10 @@ +
+
Scale
+
{{ $plan->scale }}%
+