Skip to content

Commit 36b15d4

Browse files
committed
Add support for scaling seating plans
When creating larger seating plans, the default scale of the grid means that the plan ends up quite big. Added a percentile-based scale which can scale the layout grid down (or up) to help with larger layouts.
1 parent 6a835ac commit 36b15d4

File tree

7 files changed

+53
-2
lines changed

7 files changed

+53
-2
lines changed

_ide_helper_models.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ class IdeHelperSeat {}
344344
* @property int $order
345345
* @property int $revision
346346
* @property string|null $image_url
347+
* @property int $scale
347348
* @property \Illuminate\Support\Carbon|null $created_at
348349
* @property \Illuminate\Support\Carbon|null $updated_at
349350
* @property-read \App\Models\Event $event

app/Http/Controllers/Admin/SeatingPlanController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ protected function updateObject(SeatingPlan $plan, Request $request)
3535
{
3636
$plan->name = $request->input('name');
3737
$plan->image_url = $request->input('image_url');
38+
$plan->scale = $request->input('scale') ? $request->input('scale') : 100;
3839
$plan->save();
3940
}
4041

app/Http/Requests/Admin/SeatingPlanUpdateRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function (string $attribute, mixed $value, Closure $fail) {
3838
},
3939
],
4040
'image_url' => 'sometimes|url:http,https|nullable',
41+
'scale' => 'sometimes|integer|numeric|min:25|max:200|nullable',
4142
];
4243
}
4344
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('seating_plans', function (Blueprint $table) {
15+
$table->integer('scale')->default(100)->after('order');
16+
});
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*/
22+
public function down(): void
23+
{
24+
Schema::table('seating_plans', function (Blueprint $table) {
25+
$table->dropColumn('scale');
26+
});
27+
}
28+
};

resources/views/admin/seatingplans/_form.blade.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,20 @@
2222
@enderror
2323
</div>
2424
</div>
25+
<div class="mb-3">
26+
<label class="form-label">Scale</label>
27+
<div>
28+
<div class="input-group">
29+
<input type="text" name="scale" class="form-control @error('scale') is-invalid @enderror"
30+
placeholder="100" value="{{ old('scale', $plan->scale ?? '') }}">
31+
<div class="input-group-prepend">
32+
<div class="input-group-text">%</div>
33+
</div>
34+
</div>
35+
<small class="form-hint">The scale of the seating plan grid, expressed as a percentile. Valid range is 25-200.</small>
36+
@error('scale')
37+
<p class="invalid-feedback">{{ $message }}</p>
38+
@enderror
39+
</div>
40+
</div>
2541
</div>

resources/views/admin/seatingplans/show.blade.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
</span>
5959
</div>
6060
</div>
61+
<div class="datagrid-item">
62+
<div class="datagrid-title">Scale</div>
63+
<div class="datagrid-content">{{ $plan->scale }}%</div>
64+
</div>
6165
</div>
6266
</div>
6367
<div class="card-footer align-content-end d-flex btn-list">
@@ -148,7 +152,7 @@ class="btn btn-primary">
148152
@endphp
149153
<a class="d-block seat {{ $seat->class }} {{ $class }}"
150154
href="{{ route('admin.events.seatingplans.seats.show', [$event->code, $plan->id, $seat->id]) }}"
151-
style="left: {{ $seat->x * 2 }}em; top: {{ $seat->y * 2 }}em;"
155+
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;"
152156
data-bs-trigger="hover" data-bs-toggle="popover"
153157
data-bs-placement="right" data-bs-html="true"
154158
title="{{ $seat->description }} {{ $seat->label }}"

resources/views/seatingplans/_plan.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
@if($canPick)
5757
href="{{ $url }}"
5858
@endif
59-
style="left: {{ $seat->x * 2 }}em; top: {{ $seat->y * 2 }}em;"
59+
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;"
6060
data-bs-trigger="hover" data-bs-toggle="popover"
6161
data-bs-placement="right" data-bs-html="true"
6262
title="{{ $seat->description }} {{ $seat->label }}"

0 commit comments

Comments
 (0)