From 36b15d4f7f898930990142161c8346596562c4ad Mon Sep 17 00:00:00 2001 From: Adam McKissock Date: Wed, 4 Sep 2024 17:43:13 +0100 Subject: [PATCH 1/5] 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. --- _ide_helper_models.php | 1 + .../Admin/SeatingPlanController.php | 1 + .../Admin/SeatingPlanUpdateRequest.php | 1 + ...9_04_154938_add_scale_to_seating_plans.php | 28 +++++++++++++++++++ .../views/admin/seatingplans/_form.blade.php | 16 +++++++++++ .../views/admin/seatingplans/show.blade.php | 6 +++- resources/views/seatingplans/_plan.blade.php | 2 +- 7 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2024_09_04_154938_add_scale_to_seating_plans.php diff --git a/_ide_helper_models.php b/_ide_helper_models.php index 00780f05..18a6b80a 100644 --- a/_ide_helper_models.php +++ b/_ide_helper_models.php @@ -344,6 +344,7 @@ class IdeHelperSeat {} * @property int $order * @property int $revision * @property string|null $image_url + * @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..4daa67e1 100644 --- a/app/Http/Controllers/Admin/SeatingPlanController.php +++ b/app/Http/Controllers/Admin/SeatingPlanController.php @@ -35,6 +35,7 @@ protected function updateObject(SeatingPlan $plan, Request $request) { $plan->name = $request->input('name'); $plan->image_url = $request->input('image_url'); + $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_to_seating_plans.php b/database/migrations/2024_09_04_154938_add_scale_to_seating_plans.php new file mode 100644 index 00000000..36f2a178 --- /dev/null +++ b/database/migrations/2024_09_04_154938_add_scale_to_seating_plans.php @@ -0,0 +1,28 @@ +integer('scale')->default(100)->after('order'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('seating_plans', function (Blueprint $table) { + $table->dropColumn('scale'); + }); + } +}; 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..d1bc1c04 100644 --- a/resources/views/admin/seatingplans/show.blade.php +++ b/resources/views/admin/seatingplans/show.blade.php @@ -58,6 +58,10 @@ +
+
Scale
+
{{ $plan->scale }}%
+