protected function addTorrents(Request $request, TorrentManager $torrentManager) { $files = $request->request->get('add-torrent-files'); $magnets = $request->request->get('add-torrent-magnets'); $torrentsDir = $torrentManager->getTorrentsDirectory() . DIRECTORY_SEPARATOR; if ($files) { foreach ($files as $file) { $torrentPath = $torrentsDir . $file; if (file_exists($torrentPath)) { $torrentManager->addTorrentFromFile($torrentPath); } } } if ($magnets) { foreach ($magnets as $magnet) { $torrentManager->addTorrentFromMagnet($magnet); } } return $this->success(); }