Change import users
This commit is contained in:
parent
57814cace9
commit
77d30bf9a8
@ -16,7 +16,6 @@ use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
// use Maatwebsite\Excel\Excel as ExcelType;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class UserController extends Controller
|
||||
@ -144,20 +143,10 @@ class UserController extends Controller
|
||||
$disk = 'imports';
|
||||
$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(
|
||||
import: new UsersWithSmartUsersImport($file_logos),
|
||||
filePath: $filename,
|
||||
disk: $disk,
|
||||
// readerType: $type
|
||||
);
|
||||
|
||||
return response()
|
||||
@ -166,7 +155,7 @@ class UserController extends Controller
|
||||
} catch (\Throwable $th) {
|
||||
throw $th;
|
||||
} 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\User;
|
||||
|
||||
use Illuminate\Http\File;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||
use ZanySoft\Zip\Facades\Zip;
|
||||
|
||||
@ -113,11 +115,11 @@ class UsersWithSmartUsersImport implements ToCollection
|
||||
$picture = new File($temp_file_path);
|
||||
$pathS3 = "avatars/{$picture->hashName()}";
|
||||
|
||||
Storage::disk('s3')->put($pathS3, $picture->getContent());
|
||||
Storage::disk('s3')->missing($pathS3) && Storage::disk('s3')->put($pathS3, $picture->getContent());
|
||||
|
||||
$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);
|
||||
});
|
||||
|
||||
@ -74,7 +74,7 @@
|
||||
"@php artisan config:clear --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"
|
||||
},
|
||||
"extra": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user