новый дизайн
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Concerns\BuildsPortalProps;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\UpdateAccountAccessRequest;
|
||||
use App\Services\AzerothCoreAccountService;
|
||||
@@ -9,16 +10,18 @@ use App\Services\InviteCodeService;
|
||||
use App\Support\WowData;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class AccountController extends Controller
|
||||
{
|
||||
use BuildsPortalProps;
|
||||
|
||||
public function index(
|
||||
Request $request,
|
||||
AzerothCoreAccountService $accounts,
|
||||
InviteCodeService $inviteCodes,
|
||||
): View
|
||||
{
|
||||
): Response {
|
||||
$search = trim((string) $request->query('search', ''));
|
||||
$searchTerm = $search !== '' ? $search : null;
|
||||
$activeTab = (string) $request->query('tab', AzerothCoreAccountService::ACCOUNT_TAB_PLAYERS);
|
||||
@@ -29,8 +32,32 @@ class AccountController extends Controller
|
||||
|
||||
$accountStats = $accounts->accountTypeStats($searchTerm);
|
||||
|
||||
return view('admin.accounts.index', [
|
||||
'accounts' => $accounts->listAccounts($searchTerm, $activeTab),
|
||||
$accountItems = $accounts->listAccounts($searchTerm, $activeTab)
|
||||
->map(fn (array $account): array => [
|
||||
...collect($account)->except('characters')->all(),
|
||||
'email' => $account['email'] !== '' ? $account['email'] : 'email не указан',
|
||||
'status_label' => $account['locked'] ? 'Заблокирован' : 'Активен',
|
||||
'characters' => $account['characters']->values()->all(),
|
||||
'update_access_url' => route('admin.accounts.access.update', $account['id']),
|
||||
])
|
||||
->values()
|
||||
->all();
|
||||
|
||||
$invites = $inviteCodes->latest()
|
||||
->map(fn ($invite): array => [
|
||||
'id' => $invite->id,
|
||||
'code' => $invite->code,
|
||||
'created_by' => $invite->created_by_username ?: '—',
|
||||
'created_at' => $invite->created_at?->format('d.m.Y H:i'),
|
||||
'redeemed' => $invite->redeemed_at !== null,
|
||||
'redeemed_by' => $invite->redeemed_by_username ?: 'ещё не использован',
|
||||
])
|
||||
->values()
|
||||
->all();
|
||||
|
||||
return Inertia::render('Admin/Accounts', [
|
||||
...$this->portalProps($request),
|
||||
'accounts' => $accountItems,
|
||||
'accountStats' => $accountStats,
|
||||
'accountTabs' => [
|
||||
AzerothCoreAccountService::ACCOUNT_TAB_PLAYERS => [
|
||||
@@ -43,10 +70,18 @@ class AccountController extends Controller
|
||||
],
|
||||
],
|
||||
'activeTab' => $activeTab,
|
||||
'inviteCodes' => $inviteCodes->latest(),
|
||||
'inviteCodes' => $invites,
|
||||
'inviteStats' => $inviteCodes->stats(),
|
||||
'inviteStoreUrl' => route('admin.invite-codes.store'),
|
||||
'registrationRequiresInvite' => (bool) config('moonwell.registration.require_invite_code'),
|
||||
'search' => $search,
|
||||
'accessLevels' => WowData::securityLevels(),
|
||||
'accessLevels' => collect(WowData::securityLevels())
|
||||
->map(fn (string $label, int $value): array => compact('value', 'label'))
|
||||
->values()
|
||||
->all(),
|
||||
'old' => [
|
||||
'quantity' => $request->old('quantity', 1),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user