From 23ba4ab43987abb2a41588d2ae458db04c1abf46 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Wed, 16 Oct 2024 09:11:14 -0500 Subject: [PATCH] Add filters for printing cards on day of auditions. --- app/Http/Controllers/Admin/PrintCards.php | 18 ++++++++++++++++-- .../views/admin/print_cards/index.blade.php | 19 ++++++++++++++++++- .../views/components/form/option.blade.php | 17 +++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 resources/views/components/form/option.blade.php diff --git a/app/Http/Controllers/Admin/PrintCards.php b/app/Http/Controllers/Admin/PrintCards.php index 36510f4..78784fb 100644 --- a/app/Http/Controllers/Admin/PrintCards.php +++ b/app/Http/Controllers/Admin/PrintCards.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Models\Entry; use App\Models\Event; +use Illuminate\Support\Carbon; class PrintCards extends Controller { @@ -25,9 +26,22 @@ class PrintCards extends Controller public function print(\App\Actions\Print\PrintCards $printer) { //dump(request()->all()); - + if (request()->audition == null) { + return redirect()->back()->with('error', 'You must specify at least one audition'); + } $selectedAuditionIds = array_keys(request()->audition); - $cards = Entry::whereIn('audition_id', $selectedAuditionIds)->get(); + $cardQuery = Entry::whereIn('audition_id', $selectedAuditionIds); + + // Process Filters + if (request()->filter == 'today') { + $now = Carbon::now('America/Chicago')->format('Y-m-d'); + $cardQuery->where('created_at', '>=', $now); + } + if (request()->filter == 'idAfter') { + $firstId = request()->idAfter; + $cardQuery->where('id', '>=', $firstId); + } + $cards = $cardQuery->get(); $sorts = []; // Process submitted sort criteria foreach (request()->sort as $sortField) { diff --git a/resources/views/admin/print_cards/index.blade.php b/resources/views/admin/print_cards/index.blade.php index 7be40bd..3020f4b 100644 --- a/resources/views/admin/print_cards/index.blade.php +++ b/resources/views/admin/print_cards/index.blade.php @@ -26,7 +26,7 @@ {{--Sort Options--}} - + Card Sorting
@@ -52,6 +52,23 @@
+ + {{--Filter Options--}} + + Filters +
+
+ + + + + + + +
+
+
+ Print Cards @endforeach diff --git a/resources/views/components/form/option.blade.php b/resources/views/components/form/option.blade.php new file mode 100644 index 0000000..f7745c0 --- /dev/null +++ b/resources/views/components/form/option.blade.php @@ -0,0 +1,17 @@ +@props([ + 'name', + 'id', + 'checked' => false, + 'value', + 'option_text', +]) + +
+
+ +
+
+ + {{ $slot }} +
+