Commit d07f3100 authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

Add route for schedule group attachment from groups

parent 5bebcf24
......@@ -7,6 +7,8 @@ namespace App\Http\Controllers\Web\Admin;
use Illuminate\View\View;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Source\UseCases\GroupSchedule\AddSchedulesToGroups\ApiPresenter as ScheduleGroupPresenter;
use Source\UseCases\GroupSchedule\AddSchedulesToGroups\AddSchedulesToGroupsUseCase;
use Source\UseCases\GroupSchedule\GetGroupSchedules\WebPresenter as GroupSchedulesPresenter;
use Source\UseCases\GroupSchedule\GetGroupSchedules\GetGroupSchedulesUseCase;
use Source\UseCases\GroupUser\GetGroupUsers\WebPresenter as GroupUsersPresenter;
......@@ -74,8 +76,23 @@ class GroupRelationController extends Controller
}
public function addSchedule(): RedirectResponse
/**
* @param string $groupId
* @param \Source\UseCases\GroupSchedule\AddSchedulesToGroups\AddSchedulesToGroupsUseCase $schedulesToGroups
* @return \Illuminate\Http\RedirectResponse
* @throws \Illuminate\Validation\ValidationException
*/
public function addSchedule(string $groupId, AddSchedulesToGroupsUseCase $schedulesToGroups): RedirectResponse
{
$this->validate($this->request, [
'schedule' => 'required|string',
]);
$presenter = new ScheduleGroupPresenter();
$schedulesToGroups->addGroup($groupId);
$schedulesToGroups->addSchedule($this->request->input('schedule'));
$schedulesToGroups->attach($presenter);
return redirect()->back()->with($presenter->getViewModel());
}
}
Supports Markdown
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