Skip to content

Commit 05244d8

Browse files
committed
1.代码优化,处理IDE恼人的代码语法不提示问题
2.未开启注册时登录页不显示注册按钮 3.美化添加&编辑商品、文章、优惠券界面 4.加入SSR节点配置信息一键脚本
1 parent 50a1041 commit 05244d8

23 files changed

+252
-342
lines changed

app/Http/Controllers/AdminController.php

Lines changed: 84 additions & 84 deletions
Large diffs are not rendered by default.

app/Http/Controllers/ArticleController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function index(Request $request)
1818
{
1919
$id = $request->get('id');
2020

21-
$view['info'] = Article::where('is_del', 0)->where('id', $id)->first();
21+
$view['info'] = Article::query()->where('is_del', 0)->where('id', $id)->first();
2222
if (empty($view['info'])) {
2323
exit('文章已删除');
2424
}

app/Http/Controllers/BaseController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,31 +84,31 @@ public static function flowToGB($traffic)
8484
// 加密方式
8585
public function methodList()
8686
{
87-
return SsConfig::where('type', 1)->get();
87+
return SsConfig::query()->where('type', 1)->get();
8888
}
8989

9090
// 协议
9191
public function protocolList()
9292
{
93-
return SsConfig::where('type', 2)->get();
93+
return SsConfig::query()->where('type', 2)->get();
9494
}
9595

9696
// 混淆
9797
public function obfsList()
9898
{
99-
return SsConfig::where('type', 3)->get();
99+
return SsConfig::query()->where('type', 3)->get();
100100
}
101101

102102
// 等级
103103
public function levelList()
104104
{
105-
return Level::get()->sortBy('level');
105+
return Level::query()->get()->sortBy('level');
106106
}
107107

108108
// 系统配置
109109
public function systemConfig()
110110
{
111-
$config = Config::get();
111+
$config = Config::query()->get();
112112
$data = [];
113113
foreach ($config as $vo) {
114114
$data[$vo->name] = $vo->value;

app/Http/Controllers/CouponController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function __construct()
2727
// 优惠券列表
2828
public function couponList(Request $request)
2929
{
30-
$view['couponList'] = Coupon::where('is_del', 0)->paginate(10);
30+
$view['couponList'] = Coupon::query()->where('is_del', 0)->orderBy('id', 'desc')->paginate(10);
3131

3232
return Response::view('coupon/couponList', $view);
3333
}
@@ -106,16 +106,16 @@ public function delCoupon(Request $request)
106106
{
107107
$id = $request->get('id');
108108

109-
Coupon::where('id', $id)->update(['is_del' => 1]);
109+
Coupon::query()->where('id', $id)->update(['is_del' => 1]);
110110

111111
return Response::json(['status' => 'success', 'data' => '', 'message' => '删除成功']);
112112
}
113113

114114
// 导出优惠券
115115
public function exportCoupon(Request $request)
116116
{
117-
$cashCouponList = Coupon::where('is_del', 0)->where('status', 0)->where('type', 1)->get();
118-
$discountCouponList = Coupon::where('is_del', 0)->where('status', 0)->where('type', 2)->get();
117+
$cashCouponList = Coupon::query()->where('is_del', 0)->where('status', 0)->where('type', 1)->get();
118+
$discountCouponList = Coupon::query()->where('is_del', 0)->where('status', 0)->where('type', 2)->get();
119119

120120
$filename = '卡券' . date('Ymd');
121121
Excel::create($filename, function($excel) use($cashCouponList, $discountCouponList) {

app/Http/Controllers/EmailLogController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ function __construct()
2121
}
2222

2323
// 邮件发送日志列表
24-
public function list(Request $request)
24+
public function logList(Request $request)
2525
{
26-
$view['list'] = EmailLog::with('user')->paginate(10);
26+
$view['list'] = EmailLog::query()->with('user')->orderBy('id', 'desc')->paginate(10);
2727

28-
return Response::view('emailLog/list', $view);
28+
return Response::view('emailLog/logList', $view);
2929
}
3030

3131
}

app/Http/Controllers/LoginController.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function index(Request $request)
3636
return Redirect::back();
3737
}
3838

39-
$user = User::where('username', $username)->where('password', md5($password))->first();
39+
$user = User::query()->where('username', $username)->where('password', md5($password))->first();
4040
if (!$user) {
4141
$request->session()->flash('errorMsg', '用户名或密码错误');
4242

@@ -52,13 +52,13 @@ public function index(Request $request)
5252
}
5353

5454
// 更新登录信息
55-
User::where('id', $user['id'])->update(['last_login' => time()]);
55+
User::query()->where('id', $user['id'])->update(['last_login' => time()]);
5656

5757
// 登录送积分
5858
if (self::$config['login_add_score']) {
5959
if (!Cache::has('loginAddScore_' . md5($username))) {
6060
$score = mt_rand(self::$config['min_rand_score'], self::$config['max_rand_score']);
61-
$ret = User::where('id', $user['id'])->increment('score', $score);
61+
$ret = User::query()->where('id', $user['id'])->increment('score', $score);
6262
if ($ret) {
6363
$obj = new UserScoreLog();
6464
$obj->user_id = $user['id'];
@@ -77,7 +77,7 @@ public function index(Request $request)
7777
}
7878

7979
// 重新取出用户信息
80-
$user = User::where('id', $user['id'])->first();
80+
$user = User::query()->where('id', $user['id'])->first();
8181

8282
$request->session()->put('user', $user->toArray());
8383

@@ -88,7 +88,9 @@ public function index(Request $request)
8888

8989
return Redirect::to('user');
9090
} else {
91-
return Response::view('login');
91+
$view['is_register'] = self::$config['is_register'];
92+
93+
return Response::view('login', $view);
9294
}
9395
}
9496

app/Http/Controllers/RegisterController.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function index(Request $request)
7474
}
7575

7676
// 校验邀请码合法性
77-
$code = Invite::where('code', $code)->where('status', 0)->first();
77+
$code = Invite::query()->where('code', $code)->where('status', 0)->first();
7878
if (empty($code)) {
7979
$request->session()->flash('errorMsg', '邀请码不可用,请更换邀请码后重试');
8080

@@ -83,7 +83,7 @@ public function index(Request $request)
8383
}
8484

8585
// 校验用户名是否已存在
86-
$exists = User::where('username', $username)->first();
86+
$exists = User::query()->where('username', $username)->first();
8787
if ($exists) {
8888
$request->session()->flash('errorMsg', '用户名已存在,请更换用户名');
8989

@@ -92,20 +92,20 @@ public function index(Request $request)
9292

9393
// 校验aff对应账号是否存在
9494
if ($aff) {
95-
$affUser = User::where('id', $aff)->first();
95+
$affUser = User::query()->where('id', $aff)->first();
9696
$referral_uid = $affUser ? $aff : 0;
9797
} else {
9898
$referral_uid = 0;
9999
}
100100

101101
// 最后一个可用端口
102-
$last_user = User::orderBy('id', 'desc')->first();
102+
$last_user = User::query()->orderBy('id', 'desc')->first();
103103
$port = self::$config['is_rand_port'] ? $this->getRandPort() : $last_user->port + 1;
104104

105105
// 默认加密方式、协议、混淆
106-
$method = SsConfig::where('type', 1)->where('is_default', 1)->first();
107-
$protocol = SsConfig::where('type', 2)->where('is_default', 1)->first();
108-
$obfs = SsConfig::where('type', 3)->where('is_default', 1)->first();
106+
$method = SsConfig::query()->where('type', 1)->where('is_default', 1)->first();
107+
$protocol = SsConfig::query()->where('type', 2)->where('is_default', 1)->first();
108+
$obfs = SsConfig::query()->where('type', 3)->where('is_default', 1)->first();
109109

110110
// 创建新用户
111111
$transfer_enable = $referral_uid ? (self::$config['default_traffic'] + self::$config['referral_traffic']) * 1048576 : self::$config['default_traffic'] * 1048576;
@@ -126,7 +126,7 @@ public function index(Request $request)
126126

127127
// 更新邀请码
128128
if (self::$config['is_invite_register'] && $user->id) {
129-
Invite::where('id', $code->id)->update(['fuid' => $user->id, 'status' => 1]);
129+
Invite::query()->where('id', $code->id)->update(['fuid' => $user->id, 'status' => 1]);
130130
}
131131

132132
// 发送邮件

app/Http/Controllers/ShopController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function __construct()
2424
// 商品列表
2525
public function goodsList(Request $request)
2626
{
27-
$view['goodsList'] = Goods::where('is_del', 0)->paginate(10);
27+
$view['goodsList'] = Goods::query()->where('is_del', 0)->orderBy('id', 'desc')->paginate(10);
2828

2929
return Response::view('shop/goodsList', $view);
3030
}
@@ -124,7 +124,7 @@ public function editGoods(Request $request)
124124
'days' => $days,
125125
'status' => $status
126126
];
127-
$ret = Goods::where('id', $id)->update($data);
127+
$ret = Goods::query()->where('id', $id)->update($data);
128128
if ($ret) {
129129
$request->session()->flash('successMsg', '编辑成功');
130130
} else {
@@ -133,7 +133,7 @@ public function editGoods(Request $request)
133133

134134
return Redirect::to('shop/editGoods?id=' . $id);
135135
} else {
136-
$view['goods'] = Goods::where('id', $id)->first();
136+
$view['goods'] = Goods::query()->where('id', $id)->first();
137137

138138
return Response::view('shop/editGoods', $view);
139139
}
@@ -144,7 +144,7 @@ public function delGoods(Request $request)
144144
{
145145
$id = $request->get('id');
146146

147-
Goods::where('id', $id)->update(['is_del' => 1]);
147+
Goods::query()->where('id', $id)->update(['is_del' => 1]);
148148

149149
return Response::json(['status' => 'success', 'data' => '', 'message' => '删除成功']);
150150
}

app/Http/Controllers/SubscribeController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ public function index(Request $request, $code)
3333
}
3434

3535
// 校验合法性
36-
$subscribe = UserSubscribe::where('code', $code)->where('status', 1)->with('user')->first();
36+
$subscribe = UserSubscribe::query()->where('code', $code)->where('status', 1)->with('user')->first();
3737
if (empty($subscribe)) {
3838
exit('非法请求或者被禁用,请联系管理员');
3939
}
4040

41-
$user = User::where('id', $subscribe->user_id)->whereIn('status', [0, 1])->where('enable', 1)->first();
41+
$user = User::query()->where('id', $subscribe->user_id)->whereIn('status', [0, 1])->where('enable', 1)->first();
4242
if (empty($user)) {
4343
exit('非法请求或者被禁用,请联系管理员');
4444
}
@@ -55,13 +55,13 @@ public function index(Request $request, $code)
5555
$log->save();
5656

5757
// 获取这个账号可用节点
58-
$group_ids = SsGroup::where('level', '<=', $user->level)->select(['id'])->get();
58+
$group_ids = SsGroup::query()->where('level', '<=', $user->level)->select(['id'])->get();
5959
if (empty($group_ids)) {
6060
exit();
6161
}
6262

63-
$node_ids = SsGroupNode::whereIn('group_id', $group_ids)->select(['node_id'])->get();
64-
$nodeList = SsNode::whereIn('id', $node_ids)->get();
63+
$node_ids = SsGroupNode::query()->whereIn('group_id', $group_ids)->select(['node_id'])->get();
64+
$nodeList = SsNode::query()->whereIn('id', $node_ids)->get();
6565
$scheme = self::$config['subscribe_max'] > 0 ? 'MAX=' . self::$config['subscribe_max'] . "\n" : '';
6666
foreach ($nodeList as $node) {
6767
$obfs_param = $user->obfs_param ? $this->base64url_encode($user->obfs_param) : '';

app/Http/Controllers/TicketController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function __construct()
2424
// 工单列表
2525
public function ticketList(Request $request)
2626
{
27-
$view['ticketList'] = Ticket::paginate(10);
27+
$view['ticketList'] = Ticket::query()->orderBy('id', 'desc')->paginate(10);
2828

2929
return Response::view('ticket/ticketList', $view);
3030
}
@@ -48,15 +48,15 @@ public function replyTicket(Request $request)
4848

4949
if ($obj->id) {
5050
// 将工单置为已回复
51-
Ticket::where('id', $id)->update(['status' => 1]);
51+
Ticket::query()->where('id', $id)->update(['status' => 1]);
5252

5353
return Response::json(['status' => 'success', 'data' => '', 'message' => '回复成功']);
5454
} else {
5555
return Response::json(['status' => 'fail', 'data' => '', 'message' => '回复失败']);
5656
}
5757
} else {
58-
$view['ticket'] = Ticket::where('id', $id)->with('user')->first();
59-
$view['replyList'] = TicketReply::where('ticket_id', $id)->with('user')->orderBy('id', 'asc')->get();
58+
$view['ticket'] = Ticket::query()->where('id', $id)->with('user')->first();
59+
$view['replyList'] = TicketReply::query()->where('ticket_id', $id)->with('user')->orderBy('id', 'asc')->get();
6060

6161
return Response::view('ticket/replyTicket', $view);
6262
}
@@ -67,7 +67,7 @@ public function closeTicket(Request $request)
6767
{
6868
$id = $request->get('id');
6969

70-
$ret = Ticket::where('id', $id)->update(['status' => 2]);
70+
$ret = Ticket::query()->where('id', $id)->update(['status' => 2]);
7171
if ($ret) {
7272
return Response::json(['status' => 'success', 'data' => '', 'message' => '关闭成功']);
7373
} else {

0 commit comments

Comments
 (0)