diff --git a/app/Services/Registries/RegistryImportService.php b/app/Services/Registries/RegistryImportService.php index 3c3e773..2b8607f 100644 --- a/app/Services/Registries/RegistryImportService.php +++ b/app/Services/Registries/RegistryImportService.php @@ -31,11 +31,13 @@ class RegistryImportService { public function download($url, $dir = null): ?Asset { $info = pathinfo($url); - $path = "public/documents/registries"; - $path = $dir ? "{$path}/{$dir}/{$info['basename']}" : "{$path}/{$info['basename']}"; - $asset = Asset::query()->where(['path' => $path])->first(); - if (!$asset && Storage::put($path, Http::get($url)->body())) $asset = $this->makeAsset($path); - elseif ($asset) var_dump($asset->path); + if ($info['extension']) { + $path = "public/documents/registries"; + $path = $dir ? "{$path}/{$dir}/{$info['basename']}" : "{$path}/{$info['basename']}"; + $asset = Asset::query()->where(['path' => $path])->first(); + if (!$asset && Storage::put($path, Http::get($url)->body())) $asset = $this->makeAsset($path); + elseif ($asset) var_dump($asset->path); + } return $asset ?? null; } public function makeAsset($path, $name = null) { diff --git a/database/migrations/2017_08_08_193843_create_assets_table.php b/database/migrations/2017_08_08_193843_create_assets_table.php index 9b14ed9..381f026 100644 --- a/database/migrations/2017_08_08_193843_create_assets_table.php +++ b/database/migrations/2017_08_08_193843_create_assets_table.php @@ -17,11 +17,11 @@ class CreateAssetsTable extends Migration $table->id(); $table->char('uuid', 36)->index()->unique(); $table->bigInteger('user_id')->unsigned()->index()->nullable(); - $table->string('name')->index()->nullable(); + $table->string('name', 500)->index()->nullable(); $table->string('type', 45)->index()->nullable(); - $table->string('path', 100)->nullable(); + $table->string('path', 500)->nullable(); $table->string('mime')->nullable(); - $table->string('filename')->index()->nullable(); + $table->string('filename', 500)->index()->nullable(); $table->string('extension', 10)->index()->nullable(); $table->decimal('latitude', 8, 6)->nullable(); $table->decimal('longitude', 9, 6)->nullable();