id); // Create folder if not exist if ($folder->doesntExist()) { $this->createFolder($uploadRequest); } // Set default parent_id for uploaded file if (is_null($request->input('parent_id'))) { $request->merge(['parent_id' => $uploadRequest->id]); } // Get content from external sources if (isBroadcasting()) { ($this->getContentFromExternalSource) ->onQueue() ->execute($request->all(), $uploadRequest->user); } else { ($this->getContentFromExternalSource)($request->all(), $uploadRequest->user); } // Set timestamp for auto filling cache()->set("auto-filling.$uploadRequest->id", now()->toString()); return response('Files were successfully added to the upload queue', 201); } /** * Create root Upload Request folder */ private function createFolder(UploadRequest $uploadRequest): void { // Format timestamp $timestamp = format_date($uploadRequest->created_at, 'd. M. Y'); // Create folder DB::table('folders')->insert([ 'id' => $uploadRequest->id, 'parent_id' => $uploadRequest->folder_id ?? null, 'user_id' => $uploadRequest->user_id, 'name' => $uploadRequest->name ?? __t('upload_request_default_folder', ['timestamp' => $timestamp]), 'created_at' => now(), 'updated_at' => now(), ]); // Update upload request status $uploadRequest->update([ 'status' => 'filling', ]); } }