Skip to content

Instantly share code, notes, and snippets.

@Tjoosten
Created November 19, 2017 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tjoosten/30b6ad0a9b908a8587bffd8fdab064c9 to your computer and use it in GitHub Desktop.
Save Tjoosten/30b6ad0a9b908a8587bffd8fdab064c9 to your computer and use it in GitHub Desktop.
/**
* Delete an api key out off the storage.
*
* @param integer $keyId The unique identifier in the storage.
* @return \Illuminate\Http\RedirectResponse
*/
public function delete($keyId): RedirectResponse
{
$apiKey = $this->apiKeyRepository->find($keyId) ?: abort(Response::HTTP_NOT_FOUND);
if (Gate::allows('delete', $apiKey) && $apiKey->delete()) {
$this->usersRepository->find($apiKey->apikeyable_id)->notify(new ApiKeyDeleteNotification());
flash("De API sleutel voor de service {$apiKey->service} is verwijderd.")->success();
if (auth()->user()->hasRole('admin')) {
// TODO: Implement activity logger
}
}
return redirect()->to($this->apiKeyRepository->getRedirectRoute());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment