This commit is contained in:
Matt Young 2024-07-03 01:28:18 -05:00
parent 5a5207357e
commit 75ce5043c2
4 changed files with 11 additions and 10 deletions

View File

@ -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);

View File

@ -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,

View File

@ -17,7 +17,7 @@ class EventFactory extends Factory
public function definition(): array
{
return [
'name' => $this->faker->name(),
'name' => $this->faker->unique()->name(),
];
}
}

View File

@ -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'));