Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/UsersController.php
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | public function index() | ||||
$data = array_merge($data, self::userStatuses($user)); | $data = array_merge($data, self::userStatuses($user)); | ||||
return $data; | return $data; | ||||
}); | }); | ||||
return response()->json($result); | return response()->json($result); | ||||
} | } | ||||
/** | /** | ||||
* Set user config. | |||||
* | |||||
* @param int $id The user | |||||
* | |||||
* @return \Illuminate\Http\JsonResponse | |||||
*/ | |||||
public function setConfig($id) | |||||
{ | |||||
$user = User::find($id); | |||||
if (empty($user)) { | |||||
return $this->errorResponse(404); | |||||
} | |||||
if (!$this->guard()->user()->canRead($user)) { | |||||
return $this->errorResponse(403); | |||||
} | |||||
$errors = $user->setConfig(request()->input()); | |||||
if (!empty($errors)) { | |||||
return response()->json(['status' => 'error', 'errors' => $errors], 422); | |||||
} | |||||
return response()->json([ | |||||
'status' => 'success', | |||||
'message' => __('app.user-setconfig-success'), | |||||
]); | |||||
} | |||||
/** | |||||
* Display information on the user account specified by $id. | * Display information on the user account specified by $id. | ||||
* | * | ||||
* @param int $id The account to show information for. | * @param int $id The account to show information for. | ||||
* | * | ||||
* @return \Illuminate\Http\JsonResponse | * @return \Illuminate\Http\JsonResponse | ||||
*/ | */ | ||||
public function show($id) | public function show($id) | ||||
{ | { | ||||
Show All 15 Lines | public function show($id) | ||||
foreach ($user->entitlements as $ent) { | foreach ($user->entitlements as $ent) { | ||||
$sku = $ent->sku; | $sku = $ent->sku; | ||||
$response['skus'][$sku->id] = [ | $response['skus'][$sku->id] = [ | ||||
// 'cost' => $ent->cost, | // 'cost' => $ent->cost, | ||||
'count' => isset($response['skus'][$sku->id]) ? $response['skus'][$sku->id]['count'] + 1 : 1, | 'count' => isset($response['skus'][$sku->id]) ? $response['skus'][$sku->id]['count'] + 1 : 1, | ||||
]; | ]; | ||||
} | } | ||||
$response['config'] = $user->getConfig(); | |||||
return response()->json($response); | return response()->json($response); | ||||
} | } | ||||
/** | /** | ||||
* Fetch user status (and reload setup process) | * Fetch user status (and reload setup process) | ||||
* | * | ||||
* @param int $id User identifier | * @param int $id User identifier | ||||
* | * | ||||
▲ Show 20 Lines • Show All 692 Lines • Show Last 20 Lines |