Skip to content

Commit

Permalink
Merge pull request #8 from romo4ko/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
romo4ko authored Oct 27, 2024
2 parents 677e7bc + 631db2f commit f7c589f
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 38 deletions.
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

0 comments on commit f7c589f

Please sign in to comment.