Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #8

Merged
merged 4 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Filament/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static function form(Form $form): Form
->disabled()
->nullable(),
Forms\Components\Section::make()->schema([
Forms\Components\Checkbox::make('is_confirmed')->label('Верифицирован'),
Forms\Components\Checkbox::make('is_confirmed')->label('Проверен'),
Forms\Components\Checkbox::make('is_admin')->label('Администратор'),
])->columns(2),
Forms\Components\TextInput::make('password')
Expand Down
44 changes: 43 additions & 1 deletion app/Http/Controllers/Api/TeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@

use App\DTO\Api\Team\Request\TeamUpdateDTO;
use App\Models\Team;
use App\Models\User;
use App\Services\Api\TeamService;
use Illuminate\Http\JsonResponse;

class TeamController extends Controller
{
public function __construct(
protected TeamService $teamService
){
)
{
}

public function show(int $id): array
Expand Down Expand Up @@ -44,4 +46,44 @@ public function challenge(int $id): array
{
return Team::query()->find($id)?->challenges()->get()->toArray() ?? [];
}

public function delete(int $teamId, int $userId): array
{
$team = Team::query()->find($teamId);

if ($team) {
$user = $team->users()->find($userId);
if ($user) {
if (auth()->id() === $team->captain_id) {
if (auth()->id() !== $user->id) {
$team->users()->detach($user->id);

return $team->users()->get()->toArray();
}
}
}
}

return [];
}

public function joinMember(int $teamId, int $userId): array
{
$user = User::query()->find($userId);
$team = Team::query()->find($teamId);

if ($user && $team) {
$team->users()->attach($user->id);

if ($user->telegram_id) {
$tg = new TelegramController();

$tg->sendMessage($user->telegram_id, 'вы были приглашены в команду - ' . $team->name);
}

return $team->users()->get()->toArray();
}

return [];
}
}
Binary file modified public/favicon.ico
Binary file not shown.
Loading
Loading