/** * POST /oauth/clients */ public function registerClient(Request $request) { $clientIdentifier = $this->generator->generate(40); $clientSecret = $this->generator->generate(40); try { $client = $this->clients->create(['id' => $clientIdentifier, 'secret' => $clientSecret, 'name' => $request->get('name')]); foreach ($request->get('redirect_uris') as $uri) { $this->endpoints->create(['client_id' => $clientIdentifier, 'redirect_uri' => $uri]); } return $this->respond($client->toArrayForApi()); } catch (\Exception $e) { return $this->respondBadRequest(); } }
/** * Process an uploaded file and store it in a web-accessible place. * * @param UploadedFile $file * @param string $publishFilename * * @throws \Exception */ public function process(UploadedFile $file, $publishFilename) { // Temporary filename to work with. $tempFilename = $this->generator->generate(40); try { $file->move($this->publishDir, $tempFilename); $speakerPhoto = Image::make($this->publishDir . '/' . $tempFilename); if ($speakerPhoto->height > $speakerPhoto->width) { $speakerPhoto->resize($this->size, null, true); } else { $speakerPhoto->resize(null, $this->size, true); } $speakerPhoto->crop($this->size, $this->size); if ($speakerPhoto->save($this->publishDir . '/' . $publishFilename)) { unlink($this->publishDir . '/' . $tempFilename); } } catch (\Exception $e) { unlink($this->publishDir . '/' . $tempFilename); throw $e; } }