mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-02-08 18:08:13 -05:00
fix(ticket): correct knows issues
This commit is contained in:
parent
0232bb90dc
commit
c7dd798af3
@ -55,9 +55,10 @@ class TicketController extends Controller
|
||||
if (!$ticket) {
|
||||
return $this->fail([400202, '工单不存在']);
|
||||
}
|
||||
|
||||
$ticket->user = UserController::transformUserData($ticket->user);
|
||||
$ticket->messages->each(function ($message) use ($ticket) {
|
||||
$message->is_me = $message->user_id !== $ticket->user_id;
|
||||
|
||||
});
|
||||
|
||||
return $this->success($ticket);
|
||||
@ -84,13 +85,20 @@ class TicketController extends Controller
|
||||
});
|
||||
|
||||
$this->applyFiltersAndSorts($request, $ticketModel);
|
||||
|
||||
return response()->json($ticketModel
|
||||
$tickets = $ticketModel
|
||||
->latest('updated_at')
|
||||
->paginate(
|
||||
perPage: $request->integer('pageSize', 10),
|
||||
page: $request->integer('current', 1)
|
||||
));
|
||||
);
|
||||
$tickets->getCollection()->transform(function ($ticket) {
|
||||
$ticket->user = UserController::transformUserData($ticket->user);
|
||||
return $ticket;
|
||||
});
|
||||
return response([
|
||||
'data' => $tickets->items(),
|
||||
'total' => $tickets->total()
|
||||
]);
|
||||
}
|
||||
|
||||
public function reply(Request $request)
|
||||
|
@ -160,7 +160,7 @@ class UserController extends Controller
|
||||
->paginate($pageSize, ['*'], 'page', $current);
|
||||
|
||||
$users->getCollection()->transform(function ($user) {
|
||||
return $this->transformUserData($user);
|
||||
return self::transformUserData($user);
|
||||
});
|
||||
|
||||
return response([
|
||||
@ -175,7 +175,7 @@ class UserController extends Controller
|
||||
* @param User $user
|
||||
* @return User
|
||||
*/
|
||||
private function transformUserData(User $user): User
|
||||
public static function transformUserData(User $user): User
|
||||
{
|
||||
$user->subscribe_url = Helper::getSubscribeUrl($user->token);
|
||||
$user->balance = $user->balance / 100;
|
||||
|
Loading…
Reference in New Issue
Block a user