Add ability to edit rooms
This commit is contained in:
parent
ff663628ae
commit
6361f404d8
|
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Events\RoomJudgeChange;
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Audition;
|
|
||||||
use App\Models\Room;
|
use App\Models\Room;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
@ -19,7 +17,6 @@ class RoomController extends Controller
|
||||||
if (! Auth::user()->is_admin) {
|
if (! Auth::user()->is_admin) {
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
//$unassignedAuditions = Audition::with('entries')->where('room_id','=','0')->orderBy('score_order')->get();
|
|
||||||
$rooms = Room::with('auditions.entries')->orderBy('name')->get();
|
$rooms = Room::with('auditions.entries')->orderBy('name')->get();
|
||||||
|
|
||||||
return view('admin.rooms.index', ['rooms' => $rooms]);
|
return view('admin.rooms.index', ['rooms' => $rooms]);
|
||||||
|
|
@ -89,7 +86,24 @@ class RoomController extends Controller
|
||||||
return redirect()->route('admin.rooms.index')->with('success', 'Room created.');
|
return redirect()->route('admin.rooms.index')->with('success', 'Room created.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function destroy(Request $request, Room $room)
|
public function update(Request $request, Room $room)
|
||||||
|
{
|
||||||
|
if (! Auth::user()->is_admin) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
$validData = $request->validate([
|
||||||
|
'name' => 'required',
|
||||||
|
'description' => 'nullable',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$room->name = $validData['name'];
|
||||||
|
$room->description = $validData['description'];
|
||||||
|
$room->save();
|
||||||
|
|
||||||
|
return redirect()->route('admin.rooms.index')->with('success', 'Room updated.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Room $room)
|
||||||
{
|
{
|
||||||
if (! Auth::user()->is_admin) {
|
if (! Auth::user()->is_admin) {
|
||||||
abort(403);
|
abort(403);
|
||||||
|
|
@ -103,7 +117,4 @@ class RoomController extends Controller
|
||||||
|
|
||||||
return redirect()->route('admin.rooms.index')->with('success', 'Room deleted.');
|
return redirect()->route('admin.rooms.index')->with('success', 'Room deleted.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO need to be able to add new rooms. Dispatch RoomJudgeChange when we do.
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<x-modal-body>
|
||||||
|
<x-slot:title class="font-semibold">Edit Room - {{ $room->name }}</x-slot:title>
|
||||||
|
<x-form.form method="PATCH" action="{{ route('admin.rooms.update',['room'=>$room->id]) }}">
|
||||||
|
<x-form.field name="name" label_text="Room Name" value="{{ $room->name }}" />
|
||||||
|
<x-form.field name="description" label_text="Room Description" value="{{ $room->description }}" />
|
||||||
|
<x-form.button class="mt-3">Save Changes</x-form.button>
|
||||||
|
</x-form.form>
|
||||||
|
</x-modal-body>
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<x-card.card>
|
<x-card.card x-data="{ showModal: false }" class="relative">
|
||||||
<x-card.heading>
|
@include('admin.rooms.index-edit-room-modal')
|
||||||
|
<x-card.heading @click=" showModal = ! showModal">
|
||||||
{{ $room->name }}
|
{{ $room->name }}
|
||||||
<x-slot:subheading>{{ $room->description }}</x-slot:subheading>
|
<x-slot:subheading>{{ $room->description }}</x-slot:subheading>
|
||||||
<x-slot:right_side>
|
<x-slot:right_side>
|
||||||
|
|
@ -25,6 +26,5 @@
|
||||||
<x-card.list.row-text-subtext>{{ $audition->name }}</x-card.list.row-text-subtext>
|
<x-card.list.row-text-subtext>{{ $audition->name }}</x-card.list.row-text-subtext>
|
||||||
</x-card.list.row>
|
</x-card.list.row>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
</x-card.list.body>
|
</x-card.list.body>
|
||||||
</x-card.card>
|
</x-card.card>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
@props(['title'=>false])
|
||||||
|
<div
|
||||||
|
class="fixed inset-0 z-30 flex items-center justify-center overflow-auto bg-black bg-opacity-50"
|
||||||
|
x-show="showModal" x-cloak
|
||||||
|
>
|
||||||
|
<!-- Modal inner -->
|
||||||
|
<div
|
||||||
|
class="max-w-3xl px-6 py-4 mx-auto text-left bg-white rounded shadow-lg"
|
||||||
|
@click.away="showModal = false"
|
||||||
|
x-transition:enter="motion-safe:ease-out duration-300"
|
||||||
|
x-transition:enter-start="opacity-0 scale-90"
|
||||||
|
x-transition:enter-end="opacity-100 scale-100"
|
||||||
|
>
|
||||||
|
<!-- Title / Close-->
|
||||||
|
<div class="flex items-center justify-between border-b mb-2">
|
||||||
|
@if($title)
|
||||||
|
<h5 {{ $title->attributes->merge(['class' => 'mr-3 text-black max-w-none']) }}>{{ $title ?? '' }}</h5>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<button type="button" class="z-50 cursor-pointer" @click="showModal = false">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- content -->
|
||||||
|
<div>{{ $slot }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Loading…
Reference in New Issue