Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/API/V4/Admin/GroupsController.php
Show All 22 Lines | public function index() | ||||
if ($owner = User::find($owner)) { | if ($owner = User::find($owner)) { | ||||
foreach ($owner->wallets as $wallet) { | foreach ($owner->wallets as $wallet) { | ||||
$wallet->entitlements()->where('entitleable_type', Group::class)->get() | $wallet->entitlements()->where('entitleable_type', Group::class)->get() | ||||
->each(function ($entitlement) use ($result) { | ->each(function ($entitlement) use ($result) { | ||||
$result->push($entitlement->entitleable); | $result->push($entitlement->entitleable); | ||||
}); | }); | ||||
} | } | ||||
$result = $result->sortBy('namespace')->values(); | $result = $result->sortBy('name')->values(); | ||||
} | } | ||||
} elseif (!empty($search)) { | } elseif (!empty($search)) { | ||||
if ($group = Group::where('email', $search)->first()) { | if ($group = Group::where('email', $search)->first()) { | ||||
$result->push($group); | $result->push($group); | ||||
} | } | ||||
} | } | ||||
// Process the result | // Process the result | ||||
$result = $result->map(function ($group) { | $result = $result->map(function ($group) { | ||||
$data = [ | $data = [ | ||||
'id' => $group->id, | 'id' => $group->id, | ||||
'email' => $group->email, | 'email' => $group->email, | ||||
'name' => $group->name, | |||||
]; | ]; | ||||
$data = array_merge($data, self::groupStatuses($group)); | $data = array_merge($data, self::groupStatuses($group)); | ||||
return $data; | return $data; | ||||
}); | }); | ||||
$result = [ | $result = [ | ||||
'list' => $result, | 'list' => $result, | ||||
▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines |