Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/SkusController.php
Show First 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | class SkusController extends Controller | ||||
* Get a list of SKUs available to the user. | * Get a list of SKUs available to the user. | ||||
* | * | ||||
* @param int $id User identifier | * @param int $id User identifier | ||||
* | * | ||||
* @return \Illuminate\Http\JsonResponse | * @return \Illuminate\Http\JsonResponse | ||||
*/ | */ | ||||
public function userSkus($id) | public function userSkus($id) | ||||
{ | { | ||||
$user = \App\User::find($id); | $user = \App\User::withEnvTenant()->find($id); | ||||
if (empty($user)) { | if (empty($user)) { | ||||
return $this->errorResponse(404); | return $this->errorResponse(404); | ||||
} | } | ||||
if (!Auth::guard()->user()->canRead($user)) { | if (!Auth::guard()->user()->canRead($user)) { | ||||
return $this->errorResponse(403); | return $this->errorResponse(403); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | protected function skuElement($sku): ?array | ||||
if (empty($data['type'])) { | if (empty($data['type'])) { | ||||
return null; | return null; | ||||
} | } | ||||
// Use localized value, toArray() does not get them right | // Use localized value, toArray() does not get them right | ||||
$data['name'] = $sku->name; | $data['name'] = $sku->name; | ||||
$data['description'] = $sku->description; | $data['description'] = $sku->description; | ||||
unset($data['handler_class'], $data['created_at'], $data['updated_at']); | unset($data['handler_class'], $data['created_at'], $data['updated_at'], $data['fee'], $data['tenant_id']); | ||||
return $data; | return $data; | ||||
} | } | ||||
} | } |