/** * Deletes hosted app files from storage. * * @param $id * @param $storageServiceId * @param $storageFolder */ protected static function deleteHostedAppStorage($id, $storageServiceId, $storageFolder) { $app = AppModel::whereId($id)->first(); if (empty($app) && !empty($storageServiceId) && !empty($storageFolder)) { /** @type BaseFileService $storageService */ $storageService = ServiceHandler::getServiceById($storageServiceId); if ($storageService->driver()->folderExists(null, $storageFolder)) { $storageService->driver()->deleteFolder(null, $storageFolder, true); } } }
public function tearDown() { User::whereEmail('*****@*****.**')->delete(); Role::whereName('test_role')->delete(); App::whereId(1)->update(['role_id' => null]); }
/** * Returns app info cached, or reads from db if not present. * Pass in a key to return a portion/index of the cached data. * * @param int $id * @param null|string $key * @param null $default * * @return mixed|null */ public static function getCachedInfo($id, $key = null, $default = null) { $cacheKey = 'app:' . $id; try { $result = \Cache::remember($cacheKey, \Config::get('df.default_cache_ttl'), function () use($id) { $app = App::whereId('id', $id)->first(); if (empty($app)) { throw new NotFoundException("App not found."); } if (!$app->is_active) { throw new ForbiddenException("App is not active."); } return $app->toArray(); }); if (is_null($result)) { return $default; } } catch (ModelNotFoundException $ex) { return $default; } if (is_null($key)) { return $result; } return isset($result[$key]) ? $result[$key] : $default; }