Commit 6560c860 authored by Jacob Priddy's avatar Jacob Priddy 👌

Add new routes and refactor remove group to be more conformant

parent 399980c3
......@@ -197,15 +197,19 @@ class DoorsController extends Controller
/**
* @param string $doorId
* @param string $groupId
* @param \Source\UseCases\DoorGroup\RemoveDoorFromGroup\RemoveDoorFromGroupUseCase $doorGroup
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Validation\ValidationException
*/
public function removeGroup(string $doorId, string $groupId, RemoveDoorFromGroupUseCase $doorGroup): RedirectResponse
public function removeGroup(string $doorId, RemoveDoorFromGroupUseCase $doorGroup): RedirectResponse
{
$this->validate($this->request, [
'group_id' => 'required|string',
]);
$presenter = new RemoveDoorGroupPresenter();
$doorGroup->removeDoorFromGroup([$doorId], [$groupId], $presenter);
$doorGroup->removeDoorFromGroup([$doorId], [$this->request->input('group_id')], $presenter);
return redirect(route('web.admin.doors.groups', ['doorId' => $doorId]))->with($presenter->getViewModel());
}
......
<?php
namespace App\Http\Controllers\Web\Admin;
use App\Http\Controllers\Controller;
class GroupRelationController extends Controller
{
}
......@@ -199,13 +199,23 @@ class SchedulesController extends Controller
return redirect(route('web.admin.schedules.groups', ['scheduleId' => $scheduleId]))->with($presenter->getViewModel());
}
public function removeGroup(string $scheduleId, string $groupId, RemoveSchedulesFromGroupsUseCase $scheduleGroup): RedirectResponse
/**
* @param string $scheduleId
* @param \Source\UseCases\GroupSchedule\RemoveSchedulesFromGroups\RemoveSchedulesFromGroupsUseCase $scheduleGroup
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Validation\ValidationException
*/
public function removeGroup(string $scheduleId, RemoveSchedulesFromGroupsUseCase $scheduleGroup): RedirectResponse
{
$this->validate($this->request, [
'group_id' => 'required|string',
]);
$presenter = new RemoveScheduleGroupPresenter();
$scheduleGroup->addSchedule($scheduleId);
$scheduleGroup->addGroup($groupId);
$scheduleGroup->addGroup($this->request->input('group_id'));
$scheduleGroup->detach($presenter);
......
......@@ -218,15 +218,19 @@ class UsersController extends Controller
/**
* @param string $userId
* @param string $groupId
* @param \Source\UseCases\GroupUser\RemoveUserFromGroup\RemoveUserFromGroupUseCase $removeUser
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Validation\ValidationException
*/
public function removeGroup(string $userId, string $groupId, RemoveUserFromGroupUseCase $removeUser): RedirectResponse
public function removeGroup(string $userId, RemoveUserFromGroupUseCase $removeUser): RedirectResponse
{
$this->validate($this->request, [
'group_id' => 'required|string',
]);
$presenter = new RemoveUserGroupPresenter();
$removeUser->removeUserFromGroup([$userId], [$groupId], $presenter);
$removeUser->removeUserFromGroup([$userId], [$this->request->input('group_id')], $presenter);
return redirect(route('web.admin.users.groups', ['userId' => $userId]))->with($presenter->getViewModel());
}
......
<form action="{{ route('web.admin.doors.removeGroup', ['doorId' => $resourceId, 'groupId' => $id]) }}" method="POST">
<form action="{{ route('web.admin.doors.removeGroup', ['doorId' => $resourceId, 'group_id' => $id]) }}" method="POST">
@csrf
@method('DELETE')
<button class="btn btn-danger" type="submit" data-toggle="tooltip" title="Detach door from group.">
......
<form action="{{ route('web.admin.schedules.removeGroup', ['scheduleId' => $resourceId, 'groupId' => $id]) }}" method="POST">
<form action="{{ route('web.admin.schedules.removeGroup', ['scheduleId' => $resourceId, 'group_id' => $id]) }}" method="POST">
@csrf
@method('DELETE')
<button class="btn btn-danger" type="submit" data-toggle="tooltip" title="Detach schedule from group.">
......
<form action="{{ route('web.admin.users.removeGroup', ['userId' => $resourceId, 'groupId' => $id]) }}" method="POST">
<form action="{{ route('web.admin.users.removeGroup', ['userId' => $resourceId, 'group_id' => $id]) }}" method="POST">
@csrf
@method('DELETE')
<button class="btn btn-danger" type="submit" data-toggle="tooltip" title="Detach user from group.">
......
......@@ -15,6 +15,7 @@ use App\Http\Controllers\Web\Admin\AttemptsController;
use App\Http\Controllers\Web\Admin\RequestsController;
use App\Http\Controllers\Web\Admin\OverridesController;
use App\Http\Controllers\Web\Admin\SchedulesController;
use App\Http\Controllers\Web\Admin\GroupRelationController;
/*
|--------------------------------------------------------------------------
......@@ -74,7 +75,7 @@ Route::name('web.')->middleware(['auth:api'])->group(static function () {
Route::get('/{doorId}/groups', [DoorsController::class, 'groups'])->name('groups');
Route::post('/{doorId}/groups', [DoorsController::class, 'addGroup'])->name('addGroup');
Route::delete('/{doorId}/group/{groupId}', [DoorsController::class, 'removeGroup'])->name('removeGroup');
Route::delete('/{doorId}/groups', [DoorsController::class, 'removeGroup'])->name('removeGroup');
});
Route::name('users.')
......@@ -91,7 +92,7 @@ Route::name('web.')->middleware(['auth:api'])->group(static function () {
Route::get('/{userId}/groups', [UsersController::class, 'groups'])->name('groups');
Route::post('/{userId}/groups', [UsersController::class, 'addGroup'])->name('addGroup');
Route::delete('/{userId}/group/{groupId}', [UsersController::class, 'removeGroup'])->name('removeGroup');
Route::delete('/{userId}/groups', [UsersController::class, 'removeGroup'])->name('removeGroup');
});
Route::name('requests.')
......@@ -114,6 +115,19 @@ Route::name('web.')->middleware(['auth:api'])->group(static function () {
Route::put('/{groupId}', [GroupsController::class, 'update'])->name('update');
Route::delete('/{groupId}', [GroupsController::class, 'destroy'])->name('destroy');
Route::get('/{groupId}/events', [GroupsController::class, 'events'])->name('events');
Route::get('/{groupId}/doors', [GroupRelationController::class, 'doors'])->name('doors');
Route::post('/{groupId}/doors', [GroupRelationController::class, 'addDoor'])->name('addDoor');
Route::delete('{groupId}/doors', [GroupRelationController::class, 'removeDoor'])->name('removeDoor');
Route::get('/{groupId}/users', [GroupRelationController::class, 'users'])->name('users');
Route::post('/{groupId}/users', [GroupRelationController::class, 'addUser'])->name('addUser');
Route::delete('{groupId}/users', [GroupRelationController::class, 'removeUser'])->name('removeUser');
Route::get('/{groupId}/schedules', [GroupRelationController::class, 'schedules'])->name('schedules');
Route::post('/{groupId}/schedules', [GroupRelationController::class, 'addSchedule'])->name('addSchedule');
Route::delete('{groupId}/schedules', [GroupRelationController::class, 'removeSchedule'])->name('removeSchedule');
});
Route::name('schedules.')
......@@ -130,7 +144,7 @@ Route::name('web.')->middleware(['auth:api'])->group(static function () {
Route::get('/{scheduleId}/groups', [SchedulesController::class, 'groups'])->name('groups');
Route::post('/{scheduleId}/groups', [SchedulesController::class, 'addGroup'])->name('addGroup');
Route::delete('/{scheduleId}/group/{groupId}', [SchedulesController::class, 'removeGroup'])->name('removeGroup');
Route::delete('/{scheduleId}/groups', [SchedulesController::class, 'removeGroup'])->name('removeGroup');
});
Route::name('overrides.')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment