When a user creates a school, make them the head

Work on #64
This commit is contained in:
Matt Young 2024-08-10 17:25:35 -05:00
parent 0d0c182df8
commit 5862d05f35
2 changed files with 10 additions and 1 deletions

View File

@ -70,6 +70,15 @@ class SchoolController extends Controller
'schools' => [$school->id],
],
]);
auth()->user()->addFlag('head_director'); // If user is creating a school, they are initially the head
AuditLogEntry::create([
'user' => auth()->user()->email,
'ip_address' => request()->ip(),
'message' => 'Marked '.auth()->user()->full_name().' as head director for '.$school->name,
'affected' => ['schools' => [$school->id], 'users' => [auth()->user()->id]],
]);
}
return redirect('/schools/'.$school->id);

View File

@ -5,7 +5,7 @@
</x-card.heading>
<x-form.form method="POST" action="/schools" class="!mt-4">
<x-form.form method="POST" action="{{route('schools.store')}}" class="!mt-4">
<x-form.body-grid columns="6" class="max-w-full">
<x-form.field name="name" label_text="School Name" colspan="6"/>
<x-form.field name="address" label_text="School Address" colspan="6"/>