• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visavi / rotor / 27388066632

12 Jun 2026 01:15AM UTC coverage: 14.172%. Remained the same
27388066632

push

github

visavi
Исправил ошибки phpstan

0 of 36 new or added lines in 9 files covered. (0.0%)

4 existing lines in 3 files now uncovered.

816 of 5758 relevant lines covered (14.17%)

1.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/Http/Controllers/Admin/BanController.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace App\Http\Controllers\Admin;
6

7
use App\Classes\Validator;
8
use App\Models\Banhist;
9
use App\Models\User;
10
use Illuminate\Http\RedirectResponse;
11
use Illuminate\Http\Request;
12
use Illuminate\View\View;
13

14
class BanController extends AdminController
15
{
16
    /**
17
     * Главная страница
18
     */
19
    public function index(): View
×
20
    {
21
        return view('admin/bans/index');
×
22
    }
23

24
    /**
25
     * Бан пользователя
26
     */
27
    public function edit(Request $request, Validator $validator): View|RedirectResponse
×
28
    {
29
        $user = User::query()->where('login', $request->input('user'))->with('lastBan')->first();
×
30

31
        if (! $user) {
×
32
            abort(404, __('validator.user'));
×
33
        }
34

35
        if (in_array($user->level, User::ADMIN_GROUPS, true)) {
×
36
            abort(200, __('admin.bans.forbidden_ban'));
×
37
        }
38

39
        if ($request->isMethod('post')) {
×
40
            $time = int($request->input('time'));
×
41
            $type = $request->input('type');
×
42
            $reason = $request->input('reason');
×
43
            $validator
×
44
                ->false($user->level === User::BANNED && $user->timeban > SITETIME, __('admin.bans.user_banned'))
×
45
                ->gt($time, 0, ['time' => __('admin.bans.time_not_indicated')])
×
46
                ->in($type, ['minutes', 'hours', 'days'], ['type' => __('admin.bans.time_not_selected')])
×
47
                ->length($reason, 5, 1000, ['reason' => __('validator.text')]);
×
48

49
            if ($validator->isValid()) {
×
50
                if ($type === 'days') {
×
51
                    $time *= 86400;
×
52
                } elseif ($type === 'hours') {
×
53
                    $time *= 3600;
×
54
                } else {
55
                    $time *= 60;
×
56
                }
57

58
                $user->update([
×
59
                    'level'   => User::BANNED,
×
60
                    'timeban' => SITETIME + $time,
×
61
                ]);
×
62

63
                Banhist::query()->create([
×
64
                    'user_id'      => $user->id,
×
65
                    'send_user_id' => getUser('id'),
×
66
                    'type'         => Banhist::BAN,
×
67
                    'reason'       => $reason,
×
68
                    'term'         => $time,
×
69
                    'created_at'   => SITETIME,
×
70
                ]);
×
71

72
                setFlash('success', __('admin.bans.success_banned'));
×
73

74
                return redirect('admin/bans/edit?user=' . $user->login);
×
75
            }
76

77
            setInput($request->all());
×
78
            setFlash('danger', $validator->getErrors());
×
79
        }
80

81
        return view('admin/bans/edit', compact('user'));
×
82
    }
83

84
    /**
85
     * Изменение бана
86
     */
87
    public function change(Request $request, Validator $validator): View|RedirectResponse
×
88
    {
89
        $user = User::query()->where('login', $request->input('user'))->with('lastBan')->first();
×
90

91
        if (! $user) {
×
92
            abort(404, __('validator.user'));
×
93
        }
94

95
        if ($user->level !== User::BANNED || $user->timeban < SITETIME) {
×
96
            abort(200, __('admin.bans.user_not_banned'));
×
97
        }
98

99
        if ($request->isMethod('post')) {
×
100
            $reason = $request->input('reason');
×
101

NEW
102
            $timeban = (int) strtotime((string) $request->input('timeban'));
×
103
            $term = $timeban - SITETIME;
×
104

105
            $validator
×
106
                ->gt($term, 0, ['timeban' => __('admin.bans.time_empty')])
×
107
                ->length($reason, 5, 1000, ['reason' => __('validator.text')]);
×
108

109
            if ($validator->isValid()) {
×
110
                $user->update([
×
111
                    'level'   => User::BANNED,
×
112
                    'timeban' => $timeban,
×
113
                ]);
×
114

115
                Banhist::query()->create([
×
116
                    'user_id'      => $user->id,
×
117
                    'send_user_id' => getUser('id'),
×
118
                    'type'         => Banhist::CHANGE,
×
119
                    'reason'       => $reason,
×
120
                    'term'         => $term,
×
121
                    'created_at'   => SITETIME,
×
122
                ]);
×
123

124
                setFlash('success', __('main.record_changed_success'));
×
125

126
                return redirect('admin/bans/edit?user=' . $user->login);
×
127
            }
128

129
            setInput($request->all());
×
130
            setFlash('danger', $validator->getErrors());
×
131
        }
132

133
        return view('admin/bans/change', compact('user'));
×
134
    }
135

136
    /**
137
     * Снятие бана
138
     */
139
    public function unban(Request $request): RedirectResponse
×
140
    {
141
        $user = User::query()->where('login', $request->input('user'))->with('lastBan')->first();
×
142

143
        if (! $user) {
×
144
            abort(404, __('validator.user'));
×
145
        }
146

147
        if ($user->level !== User::BANNED || $user->timeban < SITETIME) {
×
148
            abort(200, __('admin.bans.user_not_banned'));
×
149
        }
150

151
        $user->update([
×
152
            'level'   => User::USER,
×
153
            'timeban' => null,
×
154
        ]);
×
155

156
        Banhist::query()->create([
×
157
            'user_id'      => $user->id,
×
158
            'send_user_id' => getUser('id'),
×
159
            'type'         => Banhist::UNBAN,
×
160
            'created_at'   => SITETIME,
×
161
        ]);
×
162

163
        setFlash('success', __('admin.bans.success_unbanned'));
×
164

165
        return redirect('admin/bans/edit?user=' . $user->login);
×
166
    }
167
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc