minor fix

master
Константин 2023-08-22 15:16:32 +03:00
parent 8fb20882bb
commit f51559fa65
2 changed files with 10 additions and 8 deletions

View File

@ -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) {

View File

@ -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();