feat(admin): clients controller
This commit is contained in:
parent
cf2abfccf7
commit
1985bd68ca
3 changed files with 10 additions and 20 deletions
|
@ -18,22 +18,12 @@ class CreateClientController extends AbstractListController
|
|||
$actor = RequestUtil::getActor($request);
|
||||
$actor->assertAdmin();
|
||||
|
||||
$data = Arr::get($request->getParsedBody(), 'data', []);
|
||||
$attributes = Arr::get($request->getParsedBody(), 'data.attributes');
|
||||
|
||||
$client = Client::build(
|
||||
Arr::get($data, 'attributes.name'),
|
||||
$actor->id,
|
||||
Arr::get($data, 'attributes.icon'),
|
||||
Arr::get($data, 'attributes.description'),
|
||||
Arr::get($data, 'attributes.actions'),
|
||||
Arr::get($data, 'attributes.metrics'),
|
||||
Arr::get($data, 'attributes.requirements'),
|
||||
|
||||
);
|
||||
|
||||
|
||||
$client->save();
|
||||
|
||||
return $client;
|
||||
return Client::create([
|
||||
'client_id' => Arr::get($attributes, 'client_id'),
|
||||
'client_secret' => Arr::get($attributes, 'client_secret'),
|
||||
'user_id' => $actor->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,6 @@ class ListClientController extends AbstractListController
|
|||
$actor = RequestUtil::getActor($request);
|
||||
$actor->assertAdmin();
|
||||
|
||||
return Client::get();
|
||||
return Client::all();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,11 +21,11 @@ class UpdateClientController extends AbstractListController
|
|||
$id = Arr::get($request->getQueryParams(), 'id');
|
||||
$client = Client::find($id);
|
||||
|
||||
$data = Arr::get($request->getParsedBody(), 'data', []);
|
||||
$attributes = Arr::get($request->getParsedBody(), 'data.attributes', []);
|
||||
|
||||
collect(['client_id', 'client_secret', 'redirect_uri', 'grant_types', 'scope', 'client_name', 'client_desc', 'client_icon', 'client_home'])
|
||||
->each(function (string $attribute) use ($client, $data) {
|
||||
if (($val = Arr::get($data, "attributes.$attribute")) !== null) {
|
||||
->each(function (string $attribute) use ($client, $attributes) {
|
||||
if (($val = Arr::get($attributes, $attribute)) !== null) {
|
||||
$client->$attribute = $val;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue