public function delete($uid) { try { $dropbox = Dropbox::find($uid); $dropbox->delete(); } catch (Exception $e) { return ['success' => false, 'error_message' => $e->getMessage()]; } return ['success' => true]; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $entries = Dropbox::find($id)->entries; return View::make('dropboxes.show', compact('entries')); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function files($contract_guid) { // $sync_status = $this->status($contract_guid); // no longer used? $user = Dropbox::find($contract_guid); if (!$user) { throw new Symfony\Component\HttpKernel\Exception\NotFoundHttpException(); } $entries = $user->entries; $apiEntries = []; foreach ($entries->toArray() as $entry) { if ($entry['is_dir']) { continue; // skip directories } // if (is_null($entry['file_sha']) || is_null($entry['etag'])) { // continue; // skip files that are not yet downloaded // } if (strrpos(basename($entry['original_path']), '.')) { $extension = substr(basename($entry['original_path']), strrpos(basename($entry['original_path']), '.')); } else { $extension = ".extensionless"; } if (is_null($entry['file_sha'])) { $local_url = 'https://' . Config::get('app.drobpox_host') . '/download/' . $entry['id']; } else { $local_url = 'https://' . Config::get('app.content_host') . '/dropbox/' . $entry['file_sha'] . $extension; } $remote_url = 'https://www.dropbox.com/home' . dirname($entry['original_path']); // TODO: URL encoding? $created_at = Carbon::createFromFormat('Y-m-d H:i:s', $entry['created_at'])->toRFC2822String(); $updated_at = Carbon::createFromFormat('Y-m-d H:i:s', $entry['updated_at'])->toRFC2822String(); $apiEntry = ['local_url' => $local_url, 'remote_url' => $remote_url, 'original_path' => $entry['original_path'], 'mime_type' => $entry['mime_type'], 'bytes' => $entry['bytes'], 'service_created_at' => $entry['service_created_at'], 'service_updated_at' => $entry['service_updated_at'], 'client_created_at' => $entry['client_created_at'], 'client_updated_at' => $entry['client_updated_at'], 'created_at' => $created_at, 'updated_at' => $updated_at, 'file_sha' => $entry['file_sha'], 'etag' => $entry['etag']]; $apiEntries[] = $apiEntry; } return [$apiEntries]; }