if ($already > 0) { throw new AlreadyWatched($body->plugin_key); } $watch = new PluginWatch(); $watch->plugin_id = $plugin->id; $user->watchs()->save($watch); $app->halt(200); }); /** * Endpoint whose action is to stop watching * a specific plugin */ $user_remove_watch = Tool::makeEndpoint(function ($key) use($app, $resourceServer) { OAuthHelper::needsScopes(['user', 'plugins']); $body = Tool::getBody(); $user = OAuthHelper::currentlyAuthed(); $plugin = Plugin::where('key', '=', $key)->first(); if (!$plugin) { throw new ResourceNotFound('Plugin', $key); } $watch = $user->watchs()->where('plugin_id', '=', $plugin->id)->first(); if ($watch) { $watch->delete(); } else { $app->halt(404); } $app->halt(200); }); $user_search = Tool::makeEndpoint(function () { OAuthHelper::needsScopes(['users:search']); $body = Tool::getBody();