Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/UsersController.php
<?php | <?php | ||||
namespace App\Http\Controllers\API\V4; | namespace App\Http\Controllers\API\V4; | ||||
use App\Http\Controllers\RelationController; | use App\Http\Controllers\RelationController; | ||||
use App\Domain; | use App\Domain; | ||||
use App\Plan; | |||||
use App\Rules\Password; | use App\Rules\Password; | ||||
use App\Rules\UserEmailDomain; | use App\Rules\UserEmailDomain; | ||||
use App\Rules\UserEmailLocal; | use App\Rules\UserEmailLocal; | ||||
use App\Sku; | use App\Sku; | ||||
use App\User; | use App\User; | ||||
use Illuminate\Http\Request; | use Illuminate\Http\Request; | ||||
use Illuminate\Support\Facades\DB; | use Illuminate\Support\Facades\DB; | ||||
use Illuminate\Support\Facades\Validator; | use Illuminate\Support\Facades\Validator; | ||||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | public static function statusInfo($user): array | ||||
'enableFolders' => $isController && $hasCustomDomain && $hasBeta, | 'enableFolders' => $isController && $hasCustomDomain && $hasBeta, | ||||
// TODO: Make 'enableResources' working for wallet controllers that aren't account owners | // TODO: Make 'enableResources' working for wallet controllers that aren't account owners | ||||
'enableResources' => $isController && $hasCustomDomain && $hasBeta, | 'enableResources' => $isController && $hasCustomDomain && $hasBeta, | ||||
'enableRooms' => $hasMeet, | 'enableRooms' => $hasMeet, | ||||
'enableSettings' => $isController, | 'enableSettings' => $isController, | ||||
'enableUsers' => $isController, | 'enableUsers' => $isController, | ||||
'enableWallets' => $isController, | 'enableWallets' => $isController, | ||||
'enableWalletMandates' => $isController, | 'enableWalletMandates' => $isController, | ||||
'enableWalletPayments' => $isController && (!$plan || $plan->mode != 'mandate'), | 'enableWalletPayments' => $isController && (!$plan || $plan->mode != Plan::MODE_MANDATE), | ||||
'enableCompanionapps' => $hasBeta, | 'enableCompanionapps' => $hasBeta, | ||||
]; | ]; | ||||
return array_merge($process, $result); | return array_merge($process, $result); | ||||
} | } | ||||
/** | /** | ||||
* Create a new user record. | * Create a new user record. | ||||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | class UsersController extends RelationController | ||||
*/ | */ | ||||
public static function userResponse(User $user): array | public static function userResponse(User $user): array | ||||
{ | { | ||||
$response = array_merge($user->toArray(), self::objectState($user)); | $response = array_merge($user->toArray(), self::objectState($user)); | ||||
$wallet = $user->wallet(); | $wallet = $user->wallet(); | ||||
// IsLocked flag to lock the user to the Wallet page only | // IsLocked flag to lock the user to the Wallet page only | ||||
$response['isLocked'] = ($user->isRestricted() && ($plan = $wallet->plan()) && $plan->mode == 'mandate'); | $response['isLocked'] = (!$user->isActive() && ($plan = $wallet->plan()) && $plan->mode == Plan::MODE_MANDATE); | ||||
// Settings | // Settings | ||||
$response['settings'] = []; | $response['settings'] = []; | ||||
foreach ($user->settings()->whereIn('key', self::USER_SETTINGS)->get() as $item) { | foreach ($user->settings()->whereIn('key', self::USER_SETTINGS)->get() as $item) { | ||||
$response['settings'][$item->key] = $item->value; | $response['settings'][$item->key] = $item->value; | ||||
} | } | ||||
// Status info | // Status info | ||||
▲ Show 20 Lines • Show All 342 Lines • Show Last 20 Lines |