Skip to content

Commit c4327ad

Browse files
authored
Merge pull request #30 from t3rminalV/develop
Seating Plan Updates
2 parents 0eda69b + affe873 commit c4327ad

File tree

8 files changed

+87
-9
lines changed

8 files changed

+87
-9
lines changed

_ide_helper_models.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ class IdeHelperSeat {}
344344
* @property int $order
345345
* @property int $revision
346346
* @property string|null $image_url
347+
* @property string|null $image_height
348+
* @property string|null $image_width
349+
* @property int $scale
347350
* @property \Illuminate\Support\Carbon|null $created_at
348351
* @property \Illuminate\Support\Carbon|null $updated_at
349352
* @property-read \App\Models\Event $event

app/Http/Controllers/Admin/SeatingPlanController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ protected function updateObject(SeatingPlan $plan, Request $request)
3535
{
3636
$plan->name = $request->input('name');
3737
$plan->image_url = $request->input('image_url');
38+
$plan->image_height = getimagesize($request->input('image_url'))[1];
39+
$plan->image_width = getimagesize($request->input('image_url'))[0];
40+
$plan->scale = $request->input('scale') ? $request->input('scale') : 100;
3841
$plan->save();
3942
}
4043

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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
use App\Models\SeatingPlan;
4+
use Illuminate\Database\Migrations\Migration;
5+
use Illuminate\Database\Schema\Blueprint;
6+
use Illuminate\Support\Facades\Schema;
7+
8+
return new class extends Migration
9+
{
10+
/**
11+
* Run the migrations.
12+
*/
13+
public function up(): void
14+
{
15+
Schema::table('seating_plans', function (Blueprint $table) {
16+
$table->integer('scale')->default(100)->after('order');
17+
$table->integer('image_height')->after('image_url')->nullable();
18+
$table->integer('image_width')->after('image_height')->nullable();
19+
});
20+
21+
foreach (SeatingPlan::all() as $plan) {
22+
if ($plan->image_url)
23+
{
24+
$plan->image_height = getimagesize($plan->image_url)[1];
25+
$plan->image_width = getimagesize($plan->image_url)[0];
26+
$plan->save();
27+
}
28+
}
29+
}
30+
31+
/**
32+
* Reverse the migrations.
33+
*/
34+
public function down(): void
35+
{
36+
Schema::table('seating_plans', function (Blueprint $table) {
37+
$table->dropColumn('scale');
38+
$table->dropColumn('image_height');
39+
$table->dropColumn('image_width');
40+
});
41+
}
42+
};

resources/views/admin/events/seats.blade.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,13 @@ class="badge bg-muted text-muted-fg">{{ $clanMember->clan->name }}</span>
125125
style="min-width: {{ collect($seats[$plan->id] ?? [])->max('x') * 2 + 4 }}em;">
126126
<div class="card-body p-0">
127127
<div class="seating-plan" style="
128-
@if($plan->image_url)
129-
background-image:url('{{ $plan->image_url }}');
130-
@endif
131-
min-height: {{ (collect($seats[$plan->id])->max('y') * 2) + 4 }}em;"
128+
@if($plan->image_url)
129+
background-image:url('{{ $plan->image_url }}');
130+
min-height: {{ $plan->image_height}}px;
131+
min-width: {{ $plan->image_width}}px";
132+
@else
133+
min-height: {{ (collect($seats[$plan->id] ?? [])->max('y') * 2) + 4 }}em;"
134+
@endif
132135
>
133136
@foreach($seats[$plan->id] as $seat)
134137
@php
@@ -168,7 +171,7 @@ class="badge bg-muted text-muted-fg">{{ $clanMember->clan->name }}</span>
168171
@if($link)
169172
href="{{ $link }}"
170173
@endif
171-
style="left: {{ $seat->x * 2 }}em; top: {{ $seat->y * 2 }}em;"
174+
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;"
172175
data-bs-trigger="hover" data-bs-toggle="popover"
173176
data-bs-placement="right" data-bs-html="true"
174177
title="{{ $seat->description }} {{ $seat->label }}"

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: 9 additions & 2 deletions
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">
@@ -119,8 +123,11 @@ class="btn btn-primary">
119123
<div class="seating-plan" style="
120124
@if($plan->image_url)
121125
background-image:url('{{ $plan->image_url }}');
126+
min-height: {{ $plan->image_height}}px;
127+
min-width: {{ $plan->image_width}}px";
128+
@else
129+
min-height: {{ (collect($seats[$plan->id] ?? [])->max('y') * 2) + 4 }}em;"
122130
@endif
123-
min-height: {{ ($seats->max('y') * 2) + 4 }}em;"
124131
>
125132
@foreach($seats as $seat)
126133
@php
@@ -148,7 +155,7 @@ class="btn btn-primary">
148155
@endphp
149156
<a class="d-block seat {{ $seat->class }} {{ $class }}"
150157
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;"
158+
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;"
152159
data-bs-trigger="hover" data-bs-toggle="popover"
153160
data-bs-placement="right" data-bs-html="true"
154161
title="{{ $seat->description }} {{ $seat->label }}"

resources/views/seatingplans/_plan.blade.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
<div class="seating-plan" style="
33
@if($plan->image_url)
44
background-image:url('{{ $plan->image_url }}');
5+
min-height: {{ $plan->image_height}}px;
6+
min-width: {{ $plan->image_width}}px";
7+
@else
8+
min-height: {{ (collect($seats[$plan->id] ?? [])->max('y') * 2) + 4 }}em;"
59
@endif
6-
min-height: {{ (collect($seats[$plan->id] ?? [])->max('y') * 2) + 4 }}em;"
710
>
811
@foreach($seats[$plan->id] ?? [] as $seat)
912
@php
@@ -56,7 +59,7 @@
5659
@if($canPick)
5760
href="{{ $url }}"
5861
@endif
59-
style="left: {{ $seat->x * 2 }}em; top: {{ $seat->y * 2 }}em;"
62+
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;"
6063
data-bs-trigger="hover" data-bs-toggle="popover"
6164
data-bs-placement="right" data-bs-html="true"
6265
title="{{ $seat->description }} {{ $seat->label }}"

0 commit comments

Comments
 (0)