• 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

34.78
/app/Http/Controllers/Admin/SpamController.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace App\Http\Controllers\Admin;
6

7
use App\Classes\Registry;
8
use App\Classes\Validator;
9
use App\Models\Spam;
10
use Illuminate\Http\JsonResponse;
11
use Illuminate\Http\Request;
12
use Illuminate\View\View;
13

14
class SpamController extends AdminController
15
{
16
    private array $types;
17
    private string $type;
18
    private array $total = [];
19

20
    /**
21
     * SpamController constructor.
22
     */
23
    public function __construct(Request $request)
3✔
24
    {
25
        $this->types = array_merge([
3✔
26
            'messages' => __('index.messages'),
3✔
27
            'comments' => __('main.comments'),
3✔
28
        ], Registry::$spamTypes);
3✔
29

30
        $type = $request->input('type');
3✔
31

32
        $spam = Spam::query()
3✔
33
            ->selectRaw('relate_type, count(*) as total')
3✔
34
            ->groupBy('relate_type')
3✔
35
            ->pluck('total', 'relate_type')
3✔
36
            ->all();
3✔
37

38
        if ($type) {
3✔
39
            $this->type = isset($this->types[$type]) ? $type : 'post';
×
40
        } elseif ($spam) {
3✔
41
            $this->type = array_search(max($spam), $spam, true);
×
42
        } else {
43
            $this->type = 'post';
3✔
44
        }
45

46
        foreach ($this->types as $key => $value) {
3✔
47
            $this->total[$key] = $spam[$key] ?? 0;
3✔
48
        }
49
    }
50

51
    /**
52
     * Главная страница
53
     */
54
    public function index(): View
×
55
    {
56
        $type = $this->type;
×
57
        $types = $this->types;
×
58

NEW
59
        $relateWith = in_array($type, ['message', 'wall'])
×
NEW
60
            ? 'relate.author'
×
NEW
61
            : 'relate.user';
×
62

63
        $records = Spam::query()
×
64
            ->where('relate_type', $type)
×
65
            ->orderByDesc('created_at')
×
NEW
66
            ->with(['user', $relateWith])
×
67
            ->paginate(setting('spamlist'))
×
68
            ->appends(['type' => $type]);
×
69

70
        $total = $this->total;
×
71

72
        return view('admin/spam/index', compact('records', 'total', 'type', 'types'));
×
73
    }
74

75
    /**
76
     * Удаление жалоб
77
     */
78
    public function delete(Request $request, Validator $validator): JsonResponse
×
79
    {
80
        $id = int($request->input('id'));
×
81

82
        $validator
×
83
            ->true($request->ajax(), __('validator.not_ajax'))
×
84
            ->notEmpty($id, __('validator.deletion'));
×
85

86
        if ($validator->isValid()) {
×
87
            $spam = Spam::query()->find($id);
×
88

89
            if ($spam) {
×
90
                $spam->delete();
×
91
            }
92

93
            return response()->json(['success' => true]);
×
94
        }
95

96
        return response()->json([
×
97
            'success' => false,
×
98
            'message' => current($validator->getErrors()),
×
99
        ]);
×
100
    }
101
}
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