From 75ce5043c2d34a06cfee51c777cfc8fdd0fa5087 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Wed, 3 Jul 2024 01:28:18 -0500 Subject: [PATCH] Cleanup --- app/Http/Controllers/Admin/SchoolController.php | 15 +++++++-------- database/factories/AuditionFactory.php | 2 +- database/factories/EventFactory.php | 2 +- tests/Feature/Pages/EntriesIndexTest.php | 2 ++ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/Admin/SchoolController.php b/app/Http/Controllers/Admin/SchoolController.php index f8ac8c9..e0c9485 100644 --- a/app/Http/Controllers/Admin/SchoolController.php +++ b/app/Http/Controllers/Admin/SchoolController.php @@ -6,7 +6,6 @@ use App\Http\Controllers\Controller; use App\Models\School; use App\Models\SchoolEmailDomain; use App\Services\Invoice\InvoiceDataService; -use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use function abort; @@ -15,7 +14,7 @@ use function request; class SchoolController extends Controller { - protected $invoiceService; + protected InvoiceDataService $invoiceService; public function __construct(InvoiceDataService $invoiceController) { @@ -36,7 +35,7 @@ class SchoolController extends Controller return view('admin.schools.index', compact('schools', 'schoolTotalFees')); } - public function show(Request $request, School $school) + public function show(School $school) { if (! Auth::user()->is_admin) { abort(403); @@ -84,7 +83,7 @@ class SchoolController extends Controller return view('admin.schools.create'); } - public function store(Request $request) + public function store() { request()->validate([ 'name' => ['required'], @@ -105,7 +104,7 @@ class SchoolController extends Controller return redirect('/admin/schools')->with('success', 'School '.$school->name.' created'); } - public function add_domain(Request $request, School $school) + public function add_domain(School $school) { if (! Auth::user()->is_admin) { abort(403); @@ -116,13 +115,13 @@ class SchoolController extends Controller ]); SchoolEmailDomain::updateOrInsert([ 'school_id' => $school->id, - 'domain' => request('domain')], []); + 'domain' => request('domain')]); return redirect()->route('admin.schools.show', $school)->with('success', 'Domain Added'); } - public function destroy_domain(Request $request, SchoolEmailDomain $domain) + public function destroy_domain(SchoolEmailDomain $domain) { // Destroy the $domain $domain->delete(); @@ -131,7 +130,7 @@ class SchoolController extends Controller return redirect()->back(); } - public function viewInvoice(Request $request, School $school) + public function viewInvoice(School $school) { $invoiceData = $this->invoiceService->allData($school->id); diff --git a/database/factories/AuditionFactory.php b/database/factories/AuditionFactory.php index 96e5a59..484728f 100644 --- a/database/factories/AuditionFactory.php +++ b/database/factories/AuditionFactory.php @@ -42,7 +42,7 @@ class AuditionFactory extends Factory return [ 'event_id' => $event->id, #'name' => $this->faker->randomElement($instruments).$this->faker->numberBetween(1, 1000), - 'name' => 'New Instrument ' . $this->faker->sentence(5), + 'name' => 'New Instrument ' . $this->faker->unique()->sentence(5), 'score_order' => $this->faker->numberBetween(2, 50), 'entry_deadline' => Carbon::tomorrow(), 'entry_fee' => 1000, diff --git a/database/factories/EventFactory.php b/database/factories/EventFactory.php index ae4a7c9..e481e64 100644 --- a/database/factories/EventFactory.php +++ b/database/factories/EventFactory.php @@ -17,7 +17,7 @@ class EventFactory extends Factory public function definition(): array { return [ - 'name' => $this->faker->name(), + 'name' => $this->faker->unique()->name(), ]; } } diff --git a/tests/Feature/Pages/EntriesIndexTest.php b/tests/Feature/Pages/EntriesIndexTest.php index 78af1ab..e633133 100644 --- a/tests/Feature/Pages/EntriesIndexTest.php +++ b/tests/Feature/Pages/EntriesIndexTest.php @@ -141,6 +141,7 @@ it('accepts a valid entry', function () { 'student_id' => $student->id, 'audition_id' => $audition->id, ]); + /** @noinspection PhpUnhandledExceptionInspection */ $response->assertSessionHasNoErrors(); $response->assertRedirect(route('entries.index')); $this->assertDatabaseHas('entries', [ @@ -157,6 +158,7 @@ it('deletes an entry', function () { // Act actingAs($this->user); $response = delete(route('entries.destroy', $entry)); + /** @noinspection PhpUnhandledExceptionInspection */ $response ->assertSessionHasNoErrors() ->assertRedirect(route('entries.index'));