Quellcode durchsuchen

Improve data type declare & ticket, user pages display

BrettonYe vor 1 Jahr
Ursprung
Commit
4b74c6b4ee

+ 1 - 3
.gitignore

@@ -1,8 +1,6 @@
 /.phpunit.cache
 /node_modules
-/public/build
-/public/hot
-/public/storage
+/public/vendor
 /storage/*.key
 /vendor
 .env

+ 1 - 1
app/Http/Controllers/Admin/TicketController.php

@@ -29,7 +29,7 @@ class TicketController extends Controller
             });
         });
 
-        return view('admin.ticket.index', ['ticketList' => $query->latest()->paginate(10)->appends($request->except('page'))]);
+        return view('admin.ticket.index', ['ticketList' => $query->orderBy('status')->latest()->paginate(10)->appends($request->except('page'))]);
     }
 
     // 创建工单

+ 1 - 1
app/Http/Controllers/UserController.php

@@ -65,7 +65,7 @@ class UserController extends Controller
         return view('user.index', array_merge([
             'remainDays' => now()->diffInDays($user->expired_at, false),
             'resetDays' => $user->reset_time ? now()->diffInDays($user->reset_time, false) : null,
-            'unusedTraffic' => formatBytes($unusedTraffic),
+            'unusedTraffic' => $unusedTraffic,
             'expireTime' => $user->expiration_date,
             'banedTime' => $user->ban_time,
             'unusedPercent' => $totalTransfer > 0 ? round($unusedTraffic / $totalTransfer, 2) * 100 : 0,

+ 1 - 1
app/Models/Node.php

@@ -79,7 +79,7 @@ class Node extends Model
         return $this->belongsTo(__CLASS__);
     }
 
-    public function childNodes(): hasMany
+    public function childNodes(): HasMany
     {
         return $this->hasMany(__CLASS__, 'relay_node_id', 'id');
     }

+ 7 - 11
app/Models/ReferralApply.php

@@ -31,26 +31,22 @@ class ReferralApply extends Model
         return $this->belongsTo(User::class);
     }
 
-    public function referral_logs(): ReferralLog|\Illuminate\Database\Query\Builder
+    public function referral_logs(): Builder
     {
         return ReferralLog::whereIn('id', $this->link_logs);
     }
 
     protected function amountTag(): Attribute
     {
-        return Attribute::make(
-            get: fn () => Helpers::getPriceTag($this->amount),
-        );
+        return Attribute::make(get: fn () => Helpers::getPriceTag($this->amount));
     }
 
     protected function statusLabel(): Attribute
     {
-        return Attribute::make(
-            get: fn () => match ($this->status) {
-                1 => '<span class="badge badge-sm badge-info">'.trans('common.status.pending').'</span>',
-                2 => trans('common.status.withdrawn'),
-                default => '<span class="badge badge-sm badge-warning">'.trans('common.status.applying').'</span>',
-            },
-        );
+        return Attribute::make(get: fn () => match ($this->status) {
+            1 => '<span class="badge badge-sm badge-info">'.trans('common.status.pending').'</span>',
+            2 => trans('common.status.withdrawn'),
+            default => '<span class="badge badge-sm badge-warning">'.trans('common.status.applying').'</span>',
+        });
     }
 }

+ 4 - 4
app/Models/User.php

@@ -36,7 +36,7 @@ class User extends Authenticatable
 
     protected $guarded = [];
 
-    public function routeNotificationForMail($notification)
+    public function routeNotificationForMail($notification): string
     {
         return $this->username;
     }
@@ -51,17 +51,17 @@ class User extends Authenticatable
         return $this->d + $this->u;
     }
 
-    public function getExpirationDateAttribute()
+    public function getExpirationDateAttribute(): ?string
     {
         return $this->attributes['expired_at'];
     }
 
-    public function getResetDateAttribute()
+    public function getResetDateAttribute(): ?string
     {
         return $this->attributes['reset_time'];
     }
 
-    public function getTelegramUserIdAttribute()
+    public function getTelegramUserIdAttribute(): ?string
     {
         $telegram = $this->userAuths()->whereType('telegram')->first();
 

+ 3 - 3
resources/views/user/index.blade.php

@@ -40,7 +40,7 @@
                                 <i class="wb-close red-400 font-size-40 mr-10" aria-hidden="true"></i>
                                 <span class="font-size-40 font-weight-100">{{trans('common.status.expire')}}</span>
                                 <p class="font-weight-300 m-0 red-500">{{trans('user.account.reason.expired')}}</p>
-                            @elseif($unusedTraffic === '0B')
+                            @elseif($unusedTraffic === 0)
                                 <i class="wb-close red-400 font-size-40 mr-10"></i>
                                 <span class="font-size-40 font-weight-100">{{trans('common.status.disabled')}}</span>
                                 <p class="font-weight-300 m-0 red-500">{{trans('user.account.reason.traffic_exhausted')}}</p>
@@ -65,10 +65,10 @@
                                 </button>
                                 <span class="font-weight-400">{{trans('user.account.remain')}}</span>
                                 <div class="text-center font-weight-100 font-size-40">
-                                    @if ($unusedTraffic === '0B')
+                                    @if ($unusedTraffic === 0)
                                         {{trans('common.status.run_out')}}
                                     @else
-                                        {{$unusedTraffic}}
+                                        {{ formatBytes($unusedTraffic) }}
                                     @endif
                                     <br/>
                                     <h4>{{trans('user.account.level')}}: