• 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

30.77
/app/Http/Controllers/Citizen/IdentityController.php
1
<?php
2
namespace App\Http\Controllers\Citizen;
3

4
use App\Http\Controllers\Controller;
5
use Illuminate\Http\Request;
6
use Illuminate\Support\Facades\DB;
7
use Illuminate\Support\Facades\Auth;
8
use App\Models\Profile;
9
use App\Models\Feed;
10
use App\Models\User;
11
use App\Models\Proposals;
12
use App\Models\HDWallet;
13
use App\Models\CivicWallet;
14
use App\Models\Citizen;
15
use Illuminate\Support\Facades\View;
16
use App\Includes\jsonRPCClient;
17
use App\Includes\AppHelper;
18
use App\Exceptions\Handler;
19
use Exception;
20
use Carbon\Carbon;
21
use Illuminate\Support\Facades\Cache;
22

23

24
class IdentityController extends Controller
25
{
26

27
        /**
28
         * Setup the layout used by the controller.
29
         *
30
         * @return void
31
         */
32

33
        public function __construct()
2✔
34
        {
35
        }
2✔
36

37

38
        // The Gateway: citizen onboarding wizard
UNCOV
39
        public function showJoin()
×
40
        {
UNCOV
41
                if (!Auth::check()) return redirect('/login');
×
42
                $uid = Auth::user()->id;
×
43
                $profile = Profile::where('userid', $uid)->first();
×
44
                if (!$profile) return redirect('/twofa');
×
45

46
                $civic_wallet = CivicWallet::where('user_id', $uid)->first();
×
47
                if (!$civic_wallet) return redirect('/wallet/dashboard/hd');
×
48

UNCOV
49
                $citcache = Citizen::where('userid', $uid)->first();
×
50
                $view = View::make('citizen.join');
×
51
                $view->citcache = $citcache ? $citcache->toArray() : [];
×
UNCOV
52
                $view->public_address = $civic_wallet->public_addr;
×
UNCOV
53
                return $view;
×
54
        }
55

56
        //Get all public registrations and display table
57
        //
58
    public function showAll()
2✔
59
        {
60
                if (!Auth::check()) {
2✔
61
                        return redirect('/login');
1✔
62
                }
63

64
                $view = View::make('citizen.registry');
1✔
65

66
                // Shared data - cached registry lists
67
                $view->everyPublic = Cache::remember('registry_every_public', 300, function () {
1✔
68
                        return DB::select('SELECT u.*, p.*, c.*, ( SELECT f.txid FROM feed f WHERE f.userid = u.id AND f.tag = ? ORDER BY f.id DESC LIMIT 1) AS txid, ( SELECT f.mined FROM feed f WHERE f.userid = u.id AND f.tag = ? ORDER BY f.id DESC LIMIT 1) AS mined FROM users u JOIN profile p ON u.id = p.userid JOIN citizen c ON u.id = c.userid WHERE EXISTS ( SELECT 1 FROM feed f WHERE f.userid = u.id AND f.tag = ?) AND u.id NOT IN (?, ?) ORDER BY mined DESC', ['GP', 'GP', 'GP', 6462, 7601]);
1✔
69
                });
1✔
70

71
                $view->everyCitizen = Cache::remember('registry_every_citizen', 300, function () {
1✔
72
                        return DB::select('SELECT u.*, p.*, c.*, ( SELECT f.txid FROM feed f WHERE f.userid = u.id AND f.tag = ? ORDER BY f.id DESC LIMIT 1 ) AS txid, ( SELECT f.mined FROM feed f WHERE f.userid = u.id AND f.tag = ? ORDER BY f.id DESC LIMIT 1 ) AS mined FROM users u JOIN profile p ON u.id = p.userid JOIN citizen c ON u.id = c.userid WHERE EXISTS ( SELECT 1 FROM feed f WHERE f.userid = u.id AND f.tag = ? ) AND u.id NOT IN (?) ORDER BY mined DESC', ['CT', 'CT', 'CT', 6462]);
1✔
73
                });
1✔
74

75
                $view->everyApplicant = Cache::remember('registry_every_applicant', 300, function () {
1✔
76
                        return DB::select('SELECT profile.userid, users.fullname, citizen.*, civic_wallet.public_addr AS address FROM users, profile, civic_wallet, citizen WHERE profile.userid = users.id AND users.id = civic_wallet.user_id AND citizen.userid = users.id AND profile.has_application = ? AND users.id NOT IN (?) ORDER BY citizen.created_at DESC', [1, 6462]);
1✔
77
                });
1✔
78

79
                if (Auth::check()) {
1✔
80
                        $uid = Auth::user()->id;
1✔
81
                        $profile = Profile::where('userid', '=', $uid)->first();
1✔
82
                        $wallet = CivicWallet::where('user_id', '=', $uid)->first();
1✔
83
                        $citcache = Citizen::where('userid', '=', $uid)->first();
1✔
84
                        if (!$profile) {
1✔
85
                                return redirect('/twofa');
×
86
                        } else {
87
                                if ($profile->openchallenge == 1 || is_null($profile->openchallenge)) {
1✔
88
                                        return redirect('/twofachallenge');
×
89
                                }
90
                        }
91
                        $view->wallet_open = $profile->civic_wallet_open;
1✔
92
                        $view->isCitizen = $profile->citizen;
1✔
93
                        $view->citcache = $citcache;
1✔
94
                        $view->isGP  = $profile->general_public;
1✔
95
                        $view->mePublic = Feed::where('userid', '=', $uid)->where('tag', '=', "GP")->first();
1✔
96
                        $view->meCitizen = Feed::where('userid', '=', $uid)->where('tag', '=', "CT")->first();
1✔
97
                        $view->feed = Feed::where('userid', '=', $uid)->whereNotNull('mined')->whereNotIn('tag', ['GP','CT'])->orderBy('created_at', 'desc')->get();
1✔
98
                        $view->endorsed = array();
1✔
99
                        $view->recentActivityCount = Feed::where('userid', $uid)->where('mined', '>=', Carbon::now()->subDay())->count();
1✔
100

101
                        if ($wallet) {
1✔
102
                                $view->balance = AppHelper::getMarscoinBalance($wallet['public_addr']);
1✔
103
                                $view->public_address = $wallet['public_addr'];
1✔
104
                                $view->endorsed = Feed::where('message', '=', $wallet['public_addr'])->where('tag', '=', "ED")->get();
1✔
105
                        } else {
106
                                $view->balance = 0;
×
107
                                $view->public_address = "";
×
108
                        }
109
                }
110
                // Auth check at top of function ensures we never reach here unauthenticated
111

112
                return $view;
1✔
113

114
                
115
        }
116

117

118

UNCOV
119
        public function printout()
×
120
        {
UNCOV
121
                if (Auth::check()) {
×
UNCOV
122
                        $uid = Auth::user()->id;
×
123
                        $profile = Profile::where('userid', '=', $uid)->first();
×
UNCOV
124
                        $civic_wallet = CivicWallet::where('user_id', '=', $uid)->first();
×
125
                        $view = View::make('citizen.printout');
×
126
                        $citcache = Citizen::where('userid', '=', $uid)->first();
×
127
                        $view->fullname = $citcache->firstname . " " . $citcache->lastname;
×
128
                        
129
                        if ($civic_wallet) {
×
130
                                $view->public_address = $civic_wallet['public_addr'];
×
131
                        } else {
UNCOV
132
                                $view->balance = 0;
×
133
                                $view->public_address = "";
×
134
                        }
UNCOV
135
                        return $view;
×
136
                }else{
137
            return redirect('/login');
×
138
        }
139
        }
140

141

UNCOV
142
        public function printout2()
×
143
        {
UNCOV
144
                if (Auth::check()) {
×
UNCOV
145
                        $uid = Auth::user()->id;
×
UNCOV
146
                        $profile = Profile::where('userid', '=', $uid)->first();
×
147
                        $civic_wallet = CivicWallet::where('user_id', '=', $uid)->first();
×
UNCOV
148
                        $view = View::make('citizen.themes.printout2');
×
149
                        $citcache = Citizen::where('userid', '=', $uid)->first();
×
150
                        $view->fullname = $citcache->firstname . " " . $citcache->lastname;
×
151
                        
152
                        if ($civic_wallet) {
×
153
                                $view->public_address = $civic_wallet['public_addr'];
×
154
                        } else {
155
                                $view->balance = 0;
×
UNCOV
156
                                $view->public_address = "";
×
157
                        }
158
                        return $view;
×
159
                }else{
160
            return redirect('/login');
×
161
        }
162
        }
163

164

165

UNCOV
166
        public function printout3()
×
167
        {
UNCOV
168
                if (Auth::check()) {
×
UNCOV
169
                        $uid = Auth::user()->id;
×
UNCOV
170
                        $profile = Profile::where('userid', '=', $uid)->first();
×
UNCOV
171
                        $civic_wallet = CivicWallet::where('user_id', '=', $uid)->first();
×
UNCOV
172
                        $view = View::make('citizen.themes.printout3');
×
UNCOV
173
                        $citcache = Citizen::where('userid', '=', $uid)->first();
×
174
                        $view->fullname = $citcache->firstname . " " . $citcache->lastname;
×
175
                        
UNCOV
176
                        if ($civic_wallet) {
×
177
                                $view->public_address = $civic_wallet['public_addr'];
×
178
                        } else {
UNCOV
179
                                $view->balance = 0;
×
180
                                $view->public_address = "";
×
181
                        }
182
                        return $view;
×
183
                }else{
UNCOV
184
            return redirect('/login');
×
185
        }
186
        }
187

188

189

190

191
        //Get profile view of another Martian Citizen
192
        //
193
    public function showId($address)
×
194
        {
195
                
196
                if (Auth::check()) {
×
197
                        $uid = Auth::user()->id;
×
198
                        //Martian user we are looking at
199
                        $martian = Citizen::where('public_address', '=', $address)->first();
×
200
                        $martian_profile = Profile::where('userid', '=', $martian->userid)->first();
×
201
                        $martian_proposals = Proposals::where('user_id', '=', $martian->userid)->count();
×
202
                        $myprofile = Profile::where('userid', '=', $uid)->first();
×
203

UNCOV
204
                        if (!$myprofile) {
×
205
                                return redirect('/twofa');
×
206
                        } else {
207
                                if ($myprofile->openchallenge == 1 || is_null($myprofile->openchallenge)) {
×
UNCOV
208
                                        return redirect('/twofachallenge');
×
209
                                }
210
                        }
211
                        $view = View::make('citizen.martian');
×
UNCOV
212
                        $view->wallet_open = $myprofile->civic_wallet_open;
×
213

214

UNCOV
215
                        $view->isCitizen = $martian_profile->citizen;
×
UNCOV
216
                        $view->endorsements = $martian_profile->endorse_cnt;
×
UNCOV
217
                        $view->proposals = $martian_proposals;
×
UNCOV
218
                        $view->isGP  = $martian_profile->general_public;
×
UNCOV
219
                        $view->mePublic = Feed::where('userid', '=', $martian->userid)->where('tag', '=', "GP")->first();
×
UNCOV
220
                        $view->meCitizen = Feed::where('userid', '=', $martian->userid)->where('tag', '=', "CT")->first();
×
UNCOV
221
                        $view->endorsed = Feed::where('userid', '=', $martian->userid)->where('tag', '=', "ED")->count();
×
222

223

UNCOV
224
                        $view->citcache = $martian;
×
225

UNCOV
226
                        return $view;
×
227

228

229
                }else{
UNCOV
230
            return redirect('/login');
×
231
        }
232

233
                
234
        }
235

236

237

238
}
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