Event management working
This commit is contained in:
parent
1421afab5a
commit
8176b60f9d
|
|
@ -5,6 +5,8 @@ namespace App\Http\Controllers\Admin;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use function abort;
|
||||||
use function compact;
|
use function compact;
|
||||||
|
|
||||||
class EventController extends Controller
|
class EventController extends Controller
|
||||||
|
|
@ -13,4 +15,25 @@ class EventController extends Controller
|
||||||
$events = Event::all();
|
$events = Event::all();
|
||||||
return view('admin.event.index',compact('events'));
|
return view('admin.event.index',compact('events'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
if(! Auth::user()->is_admin) abort(403);
|
||||||
|
request()->validate([
|
||||||
|
'name' => ['required', 'unique:events,name'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
Event::create([
|
||||||
|
'name' => request('name'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('admin.events.index')->with('success','Event created successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request, Event $event)
|
||||||
|
{
|
||||||
|
if(! Auth::user()->is_admin) abort(403);
|
||||||
|
$event->delete();
|
||||||
|
return redirect()->route('admin.events.index')->with('success','Event deleted successfully');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
class Event extends Model
|
class Event extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
protected $guarded =[];
|
||||||
|
|
||||||
public function auditions(): HasMany
|
public function auditions(): HasMany
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
<x-help-modal>
|
||||||
|
<x-slot:title>About Events in AuditionAdmin</x-slot:title>
|
||||||
|
<ul class="text-sm text-gray-600 list-disc ml-5 space-y-2">
|
||||||
|
{{-- move help text to a popout modal --}}
|
||||||
|
<li>Events generally refer to the performance for a group of auditions</li>
|
||||||
|
<li>Every audition is assigned to one event</li>
|
||||||
|
<li>An event cannot be deleted without first deleting all of its auditions</li>
|
||||||
|
<li>Students will not be allowed to be seated in multiple auditions for the same event</li>
|
||||||
|
<li>If no student will ever be able to accept more than one seat, all auditions should be in one event</li>
|
||||||
|
<li>If you have, for example, concert bands and jazz bands that perform at different times, and a student can
|
||||||
|
make both, you should create the concert auditions in one event, and the jazz auditions in another event.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</x-help-modal>
|
||||||
|
|
@ -4,36 +4,40 @@
|
||||||
<x-card.heading>
|
<x-card.heading>
|
||||||
Manage Events
|
Manage Events
|
||||||
<x-slot:right_side>
|
<x-slot:right_side>
|
||||||
<x-help-modal>
|
@include('admin.event.index-help-modal')
|
||||||
<x-slot:title>About Events in AuditionAdmin</x-slot:title>
|
|
||||||
<ul class="text-sm text-gray-600 list-disc ml-5 space-y-2">
|
|
||||||
{{-- move help text to a popout modal --}}
|
|
||||||
<li>Events generally refer to the performance for a group of auditions</li>
|
|
||||||
<li>Every audition is assigned to one event</li>
|
|
||||||
<li>An event cannot be deleted without first deleting all of its auditions</li>
|
|
||||||
<li>Students will not be allowed to be seated in multiple auditions for the same event</li>
|
|
||||||
<li>If no student will ever be able to accept more than one seat, all auditions should be in one event</li>
|
|
||||||
<li>If you have, for example, concert bands and jazz bands that perform at different times, and a student can make both, you should create the concert auditions in one event, and the jazz auditions in another event.</li>
|
|
||||||
</ul>
|
|
||||||
</x-help-modal>
|
|
||||||
</x-slot:right_side>
|
</x-slot:right_side>
|
||||||
<x-slot:subheading>
|
|
||||||
|
|
||||||
</x-slot:subheading>
|
|
||||||
</x-card.heading>
|
</x-card.heading>
|
||||||
<x-card.list.body>
|
|
||||||
|
<x-table.table>
|
||||||
|
<x-table.body>
|
||||||
@foreach($events as $event)
|
@foreach($events as $event)
|
||||||
<x-card.list.row>
|
<tr>
|
||||||
<div class="flex items-baseline justify-between">
|
<x-table.td>{{ $event->name }}, {{ $event->auditions()->count() }} Auditions</x-table.td>
|
||||||
<span>{{ $event->name }}</span> <span class="text-sm text-gray-500">, {{ $event->auditions()->count() }} Auditions</span>
|
<x-table.td class="text-right">
|
||||||
</div>
|
|
||||||
</x-card.list.row>
|
@if($event->auditions()->count() == 0)
|
||||||
|
<form method="POST" action="{{ route('admin.events.destroy', ['event' => $event->id]) }}">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<button type="submit" class="text-red-600 text-right">Delete Event</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
|
</x-table.td>
|
||||||
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
</x-table.body>
|
||||||
{{-- The final row will allow for the creation of an event --}}
|
<tfoot>
|
||||||
<x-card.list.row>
|
<tr>
|
||||||
|
<x-form.form method="POST" :action="route('admin.events.store')" class="!px-0 !py-0">
|
||||||
</x-card.list.row>
|
<x-table.td>
|
||||||
</x-card.list.body>
|
<x-form.field name="name" label_text="Add New Event" />
|
||||||
|
</x-table.td>
|
||||||
|
<x-table.td>
|
||||||
|
<x-form.button class="mt-6">Create</x-form.button>
|
||||||
|
</x-table.td>
|
||||||
|
</x-form.form>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</x-table.table>
|
||||||
</x-card.card>
|
</x-card.card>
|
||||||
</x-layout.app>
|
</x-layout.app>
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
<!-- Modal -->
|
<!-- Modal -->
|
||||||
<div
|
<div
|
||||||
class="fixed inset-0 z-30 flex items-center justify-center overflow-auto bg-black bg-opacity-50"
|
class="fixed inset-0 z-30 flex items-center justify-center overflow-auto bg-black bg-opacity-50"
|
||||||
x-show="showModal"
|
x-show="showModal" x-cloak
|
||||||
>
|
>
|
||||||
<!-- Modal inner -->
|
<!-- Modal inner -->
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,9 @@ Route::middleware(['auth','verified',CheckIfAdmin::class])->prefix('admin/')->gr
|
||||||
|
|
||||||
// Admin Event Routes
|
// Admin Event Routes
|
||||||
Route::prefix('events')->controller(\App\Http\Controllers\Admin\EventController::class)->group(function() {
|
Route::prefix('events')->controller(\App\Http\Controllers\Admin\EventController::class)->group(function() {
|
||||||
Route::get('/','index');
|
Route::get('/','index')->name('admin.events.index');
|
||||||
|
Route::post('/','store')->name('admin.events.store');
|
||||||
|
Route::delete('/{event}','destroy')->name('admin.events.destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Admin Rooms Routes
|
// Admin Rooms Routes
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue