From 8a1fd364f887fbdb83f7e7847c33f6d046bb94df Mon Sep 17 00:00:00 2001 From: deniskorbakov Date: Sun, 27 Oct 2024 12:32:21 +0300 Subject: [PATCH] feat: update logic --- app/DTO/Api/Team/Request/TeamCreateDTO.php | 17 +++++++++++++++++ app/Http/Controllers/Api/TeamController.php | 12 ++++++++++++ routes/api.php | 5 +++-- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 app/DTO/Api/Team/Request/TeamCreateDTO.php diff --git a/app/DTO/Api/Team/Request/TeamCreateDTO.php b/app/DTO/Api/Team/Request/TeamCreateDTO.php new file mode 100644 index 0000000..e8a8224 --- /dev/null +++ b/app/DTO/Api/Team/Request/TeamCreateDTO.php @@ -0,0 +1,17 @@ +create([ + 'name' => $teamCreateDTO->name, + 'description' => $teamCreateDTO->description, + 'captain_id' => auth()->id(), + ]); + + return $team->toArray() ?? []; + } + public function show(int $id): array { return Team::query()->find($id)?->toArray() ?? []; diff --git a/routes/api.php b/routes/api.php index cf32367..7ea34a6 100755 --- a/routes/api.php +++ b/routes/api.php @@ -23,13 +23,14 @@ }); Route::group(['prefix' => 'teams'], static function () { - Route::get('/{id}', [TeamController::class, 'show'])->name('teams.show'); - Route::post('/{id}', [TeamController::class, 'update'])->name('teams.update'); + Route::post('/create', [TeamController::class, 'create'])->name('teams.create'); Route::get('/{id}/members', [TeamController::class, 'members'])->name('teams.members'); Route::get('/{id}/challenges', [TeamController::class, 'challenge'])->name('users.challenge'); Route::get('/{id}/achievements', [TeamController::class, 'achievements'])->name('teams.achievements'); Route::post('/{teamId}/delete/{userId}', [TeamController::class, 'delete'])->name('teams.delete'); Route::post('/{teamId}/join/member/{userId}', [TeamController::class, 'joinMember'])->name('teams.delete'); + Route::post('/{id}', [TeamController::class, 'update'])->name('teams.update'); + Route::get('/{id}', [TeamController::class, 'show'])->name('teams.show'); }); Route::group(['prefix' => 'challenges'], static function () {