Usando storage_path en vez de resource_path
This commit is contained in:
parent
ff96c104a2
commit
a38bceab82
5 changed files with 20 additions and 8 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -13,6 +13,8 @@ yarn-error.log
|
|||
.idea
|
||||
/resources/csv/exports/*.csv
|
||||
/resources/csv/canastas/*.csv
|
||||
/storage/csv/exports/*.csv
|
||||
/storage/csv/canastas/*.csv
|
||||
/public/css/
|
||||
/public/js/
|
||||
/public/mix-manifest.json
|
||||
|
|
|
@ -7,6 +7,7 @@ use App\CanastaLog;
|
|||
use DatabaseSeeder;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CanastaHelper
|
||||
|
@ -31,9 +32,13 @@ class CanastaHelper
|
|||
}
|
||||
|
||||
public static function guardarCanasta($data, $path): string {
|
||||
if (!File::exists(storage_path('csv/canastas'))) {
|
||||
File::makeDirectory(storage_path('csv/canastas'), 0755, true);
|
||||
}
|
||||
|
||||
$nombre = $data->getClientOriginalName();
|
||||
|
||||
$data->move(resource_path($path), $nombre);
|
||||
$data->move(storage_path($path), $nombre);
|
||||
|
||||
self::log($path . $nombre, self::ARCHIVO_SUBIDO);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Iterator;
|
||||
use League\Csv\CannotInsertRecord;
|
||||
|
@ -13,7 +14,7 @@ use League\Csv\Writer;
|
|||
class CsvHelper
|
||||
{
|
||||
public static function getRecords($filePath): Iterator {
|
||||
$csv = Reader::createFromPath(resource_path($filePath));
|
||||
$csv = Reader::createFromPath(storage_path($filePath));
|
||||
try {
|
||||
$csv->setDelimiter("|");
|
||||
$csv->setEnclosure("'");
|
||||
|
@ -27,8 +28,12 @@ class CsvHelper
|
|||
|
||||
public static function generarCsv($filePath, $contenido, $headers = null): void
|
||||
{
|
||||
if (!File::exists(storage_path('csv/exports'))) {
|
||||
File::makeDirectory(storage_path('csv/exports'), 0755, true);
|
||||
}
|
||||
|
||||
try {
|
||||
$writer = Writer::createFromPath(resource_path($filePath), 'w');
|
||||
$writer = Writer::createFromPath(storage_path($filePath), 'w');
|
||||
if ($headers) {
|
||||
$writer->insertOne($headers);
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ class AdminController extends Controller
|
|||
public function exportarPedidoACSV(GrupoDeCompra $gdc): BinaryFileResponse
|
||||
{
|
||||
$gdc->exportarPedidoEnCSV();
|
||||
$file = resource_path('csv/exports/'.$gdc->nombre.'.csv');
|
||||
$file = storage_path('csv/exports/'.$gdc->nombre.'.csv');
|
||||
return response()->download($file);
|
||||
}
|
||||
|
||||
public function exportarPedidoConNucleosACSV(GrupoDeCompra $gdc): BinaryFileResponse
|
||||
{
|
||||
$gdc->exportarPedidoConNucleosEnCSV();
|
||||
$file = resource_path('csv/exports/'.$gdc->nombre.'-completo.csv');
|
||||
$file = storage_path('csv/exports/'.$gdc->nombre.'-completo.csv');
|
||||
return response()->download($file);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,14 +21,14 @@ class ComisionesController
|
|||
public function descargarPedidos(): BinaryFileResponse
|
||||
{
|
||||
Producto::planillaTotales();
|
||||
$file = resource_path('csv/exports/pedidos-por-barrio.csv');
|
||||
$file = storage_path('csv/exports/pedidos-por-barrio.csv');
|
||||
return response()->download($file);
|
||||
}
|
||||
|
||||
public function descargarNotas(): BinaryFileResponse
|
||||
{
|
||||
Producto::planillaNotas();
|
||||
$file = resource_path('csv/exports/notas-por-barrio.csv');
|
||||
$file = storage_path('csv/exports/notas-por-barrio.csv');
|
||||
return response()->download($file);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class ComisionesController
|
|||
|
||||
public function descargarCanastaEjemplo(): BinaryFileResponse
|
||||
{
|
||||
$file = resource_path('csv/productos.csv');
|
||||
$file = storage_path('csv/productos.csv');
|
||||
return response()->download($file);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue