Merge branch 'master' of https://gitlab.com/kluppsoftware/smart-energia-api
This commit is contained in:
commit
795fc168c9
@ -16,7 +16,6 @@ use Illuminate\Http\Response;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
// use Maatwebsite\Excel\Excel as ExcelType;
|
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
@ -144,20 +143,10 @@ class UserController extends Controller
|
|||||||
$disk = 'imports';
|
$disk = 'imports';
|
||||||
$filename = $file_users->store(path: "", options: $disk);
|
$filename = $file_users->store(path: "", options: $disk);
|
||||||
|
|
||||||
// $mimeType = $file_users->getMimeType();
|
|
||||||
// $type = match($mimeType) {
|
|
||||||
// "text/csv" => ExcelType::CSV,
|
|
||||||
// "application/vnd.oasis.opendocument.spreadsheet" => ExcelType::ODS,
|
|
||||||
// "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" => ExcelType::XLSX,
|
|
||||||
// "application/vnd.ms-excel" => ExcelType::XLS,
|
|
||||||
// default => ExcelType::XLSX,
|
|
||||||
// };
|
|
||||||
|
|
||||||
Excel::import(
|
Excel::import(
|
||||||
import: new UsersWithSmartUsersImport($file_logos),
|
import: new UsersWithSmartUsersImport($file_logos),
|
||||||
filePath: $filename,
|
filePath: $filename,
|
||||||
disk: $disk,
|
disk: $disk,
|
||||||
// readerType: $type
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return response()
|
return response()
|
||||||
@ -166,7 +155,7 @@ class UserController extends Controller
|
|||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
throw $th;
|
throw $th;
|
||||||
} finally {
|
} finally {
|
||||||
Storage::disk($driver)->delete($filename);
|
Storage::disk($disk)->delete($filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,12 +4,14 @@ namespace App\Imports;
|
|||||||
|
|
||||||
use App\Models\DadosCadastrais;
|
use App\Models\DadosCadastrais;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
use Illuminate\Http\File;
|
use Illuminate\Http\File;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||||
use ZanySoft\Zip\Facades\Zip;
|
use ZanySoft\Zip\Facades\Zip;
|
||||||
|
|
||||||
@ -113,11 +115,12 @@ class UsersWithSmartUsersImport implements ToCollection
|
|||||||
$picture = new File($temp_file_path);
|
$picture = new File($temp_file_path);
|
||||||
$pathS3 = "avatars/{$picture->hashName()}";
|
$pathS3 = "avatars/{$picture->hashName()}";
|
||||||
|
|
||||||
|
Storage::disk('s3')->missing($pathS3) &&
|
||||||
Storage::disk('s3')->put($pathS3, $picture->getContent());
|
Storage::disk('s3')->put($pathS3, $picture->getContent());
|
||||||
|
|
||||||
$filename = \preg_replace("/\.[^\.]+$/", "", $filename);
|
$filename = \preg_replace("/\.[^\.]+$/", "", $filename);
|
||||||
|
|
||||||
$this->files_paths[$filename] = url('/images/test.png') ?? Storage::disk('s3')->url($pathS3);
|
$this->files_paths[$filename] = Storage::disk('s3')->url($pathS3);
|
||||||
|
|
||||||
\unlink($temp_file_path);
|
\unlink($temp_file_path);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -74,7 +74,7 @@
|
|||||||
"@php artisan config:clear --ansi",
|
"@php artisan config:clear --ansi",
|
||||||
"@php artisan schedule:clear-cache --ansi"
|
"@php artisan schedule:clear-cache --ansi"
|
||||||
],
|
],
|
||||||
"authorized-files": "sudo chown -R www-data:www-data storage/ storage/framework/cache storage/framework/cache/data bootstrap/cache/ public/",
|
"authorized-files": "sudo chown -R www-data:www-data storage/ bootstrap/cache/ public/ && sudo chown -R :www-data storage/",
|
||||||
"dev": "@php artisan serve --host=0.0.0.0 --port=8080 --ansi"
|
"dev": "@php artisan serve --host=0.0.0.0 --port=8080 --ansi"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user