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

marscoin / martianrepublic / 23749891416

30 Mar 2026 02:25PM UTC coverage: 8.467% (+3.2%) from 5.241%
23749891416

push

github

Martian Congress
fix: resolve all 10 PHPStan errors + add 37 new tests

Fixes:
- DashboardController: undefined $user/$citizen in showReports/showCamera
- AiHelperController: env() → config() for cached config safety
- BADS models: add return type hints so Larastan resolves relations
- Ballots model: add return type hints for proposal/user relations
- ErrorTriageMail: fix regex delimiter and add unicode flag
- services.php: add openrouter config block

New test suites (37 tests, 97 assertions):
- AcademyTest: 10 article page loads + 404 handling
- ForumTest: categories, threads, posts, ordering, proposal linkage
- CongressTest: ballot relations, pendingForUser, controller methods
- InstrumentTest: chain of trust, calibration, attestations, soft delete
- AiHelperTest: validation, error triage mail, severity extraction

Total: 79 tests, 161 assertions, 0 PHPStan errors

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

14 of 21 new or added lines in 8 files covered. (66.67%)

1257 existing lines in 18 files now uncovered.

445 of 5256 relevant lines covered (8.47%)

1.06 hits per line

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

0.0
/app/Http/Controllers/Inventory/InventoryController.php
1
<?php
2
namespace App\Http\Controllers\Inventory;
3

4
use Illuminate\Http\Request;
5
use Illuminate\Support\Facades\Auth;
6
use App\Models\Profile;
7
use App\Models\InventoryItem;
8
use Illuminate\Support\Facades\View;
9
use App\Http\Controllers\Controller;
10
use App\Models\CivicWallet;
11
use App\Includes\AppHelper;
12

13
class InventoryController extends Controller
14
{
15

UNCOV
16
        public function __construct()
×
17
        {
UNCOV
18
        }
×
19

UNCOV
20
        public function showAll()
×
21
        {
UNCOV
22
                $view = View::make('inventory.dashboard');
×
UNCOV
23
                $view->allItems = InventoryItem::orderBy('created_at', 'desc')->get();
×
24
                $view->categories = InventoryItem::CATEGORIES;
×
UNCOV
25
                $view->conditions = InventoryItem::CONDITIONS;
×
26

UNCOV
27
                if (Auth::check()) {
×
UNCOV
28
                        $uid = Auth::user()->id;
×
UNCOV
29
                        $profile = Profile::where('userid', '=', $uid)->first();
×
UNCOV
30
                        $wallet = CivicWallet::where('user_id', '=', $uid)->first();
×
31

UNCOV
32
                        if (!$profile) {
×
UNCOV
33
                                return redirect('/twofa');
×
34
                        }
35
                        if ($profile->openchallenge == 1 || is_null($profile->openchallenge)) {
×
36
                                return redirect('/twofachallenge');
×
37
                        }
38

39
                        $view->wallet_open = $profile->civic_wallet_open;
×
40
                        $view->isCitizen = $profile->citizen;
×
UNCOV
41
                        $view->isGP = $profile->general_public;
×
42
                        $view->balance = 0;
×
43
                        $view->public_address = "";
×
44

UNCOV
45
                        if ($wallet) {
×
UNCOV
46
                                $view->balance = AppHelper::getMarscoinBalance($wallet['public_addr']);
×
47
                                $view->public_address = $wallet['public_addr'];
×
48
                        }
49

50
                        $view->myItems = InventoryItem::where('userid', '=', $uid)->orderBy('created_at', 'desc')->get();
×
51
                } else {
UNCOV
52
                        $view->wallet_open = false;
×
53
                        $view->isCitizen = false;
×
54
                        $view->isGP = false;
×
55
                        $view->balance = 0;
×
56
                        $view->public_address = "";
×
UNCOV
57
                        $view->myItems = collect();
×
58
                }
59

UNCOV
60
                return $view;
×
61
        }
62

UNCOV
63
        public function store(Request $request)
×
64
        {
UNCOV
65
                if (!Auth::check()) {
×
66
                        return redirect('/login');
×
67
                }
68

UNCOV
69
                $uid = Auth::user()->id;
×
UNCOV
70
                $profile = Profile::where('userid', '=', $uid)->first();
×
71

UNCOV
72
                if (!$profile || !$profile->civic_wallet_open) {
×
UNCOV
73
                        return redirect('/inventory/all')->with('error', 'Wallet must be unlocked to add items.');
×
74
                }
75

UNCOV
76
                $request->validate([
×
UNCOV
77
                        'name' => 'required|string|max:255',
×
UNCOV
78
                        'description' => 'nullable|string|max:2000',
×
UNCOV
79
                        'category' => 'required|string|in:' . implode(',', array_keys(InventoryItem::CATEGORIES)),
×
UNCOV
80
                        'quantity' => 'required|integer|min:1|max:999999',
×
UNCOV
81
                        'unit' => 'nullable|string|max:50',
×
UNCOV
82
                        'location' => 'nullable|string|max:255',
×
UNCOV
83
                        'condition' => 'required|string|in:' . implode(',', array_keys(InventoryItem::CONDITIONS)),
×
UNCOV
84
                ]);
×
85

UNCOV
86
                InventoryItem::create([
×
UNCOV
87
                        'userid' => $uid,
×
UNCOV
88
                        'name' => $request->input('name'),
×
UNCOV
89
                        'description' => $request->input('description'),
×
UNCOV
90
                        'category' => $request->input('category'),
×
UNCOV
91
                        'quantity' => $request->input('quantity'),
×
UNCOV
92
                        'unit' => $request->input('unit'),
×
UNCOV
93
                        'location' => $request->input('location'),
×
UNCOV
94
                        'condition' => $request->input('condition'),
×
UNCOV
95
                ]);
×
96

UNCOV
97
                return redirect('/inventory/all')->with('success', 'Item added to inventory.');
×
98
        }
99

UNCOV
100
        public function update(Request $request, $id)
×
101
        {
UNCOV
102
                if (!Auth::check()) {
×
UNCOV
103
                        return redirect('/login');
×
104
                }
105

UNCOV
106
                $uid = Auth::user()->id;
×
UNCOV
107
                $item = InventoryItem::where('id', $id)->where('userid', $uid)->first();
×
108

UNCOV
109
                if (!$item) {
×
UNCOV
110
                        return redirect('/inventory/all')->with('error', 'Item not found.');
×
111
                }
112

UNCOV
113
                $request->validate([
×
UNCOV
114
                        'name' => 'required|string|max:255',
×
UNCOV
115
                        'description' => 'nullable|string|max:2000',
×
UNCOV
116
                        'category' => 'required|string|in:' . implode(',', array_keys(InventoryItem::CATEGORIES)),
×
UNCOV
117
                        'quantity' => 'required|integer|min:1|max:999999',
×
UNCOV
118
                        'unit' => 'nullable|string|max:50',
×
UNCOV
119
                        'location' => 'nullable|string|max:255',
×
UNCOV
120
                        'condition' => 'required|string|in:' . implode(',', array_keys(InventoryItem::CONDITIONS)),
×
UNCOV
121
                ]);
×
122

UNCOV
123
                $item->update($request->only(['name', 'description', 'category', 'quantity', 'unit', 'location', 'condition']));
×
124

UNCOV
125
                return redirect('/inventory/all')->with('success', 'Item updated.');
×
126
        }
127

UNCOV
128
        public function destroy($id)
×
129
        {
UNCOV
130
                if (!Auth::check()) {
×
UNCOV
131
                        return redirect('/login');
×
132
                }
133

UNCOV
134
                $uid = Auth::user()->id;
×
UNCOV
135
                $item = InventoryItem::where('id', $id)->where('userid', $uid)->first();
×
136

UNCOV
137
                if (!$item) {
×
UNCOV
138
                        return redirect('/inventory/all')->with('error', 'Item not found.');
×
139
                }
140

UNCOV
141
                $item->delete();
×
142

UNCOV
143
                return redirect('/inventory/all')->with('success', 'Item removed from inventory.');
×
144
        }
145
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc