Compare commits

..

No commits in common. "cc734866c5ac5b686c3b7aefa685f5d542a75308" and "95a9a404d2a0bc4b8faf2a9f3020a527ba997ce2" have entirely different histories.

3 changed files with 4 additions and 68 deletions

View File

@ -1,11 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class CanastaLog extends Model
{
protected $fillable = ["nombre", "descripcion"];
protected $table = "carga_de_canastas";
}

View File

@ -3,7 +3,6 @@
namespace App\Helpers;
use App\Proveedor;
use App\CanastaLog;
use DatabaseSeeder;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
@ -14,16 +13,12 @@ class CanastaHelper
{
const FILA_HEADER = "Tipo";
const ULTIMA_FILA = "TOTAL";
const ARCHIVO_SUBIDO = 'Archivo subido';
const CANASTA_CARGADA = 'Canasta cargada';
public static function guardarCanasta($data, $path): string {
public static function guardarCanasta($data, $path): string
{
$nombre = $data->getClientOriginalName();
$data->move(resource_path($path), $nombre);
self::log($path . $nombre, self::ARCHIVO_SUBIDO);
return $nombre;
}
@ -78,11 +73,10 @@ class CanastaHelper
];
}
foreach (array_chunk($toInsert,DatabaseSeeder::CHUNK_SIZE) as $chunk) {
foreach (array_chunk($toInsert,DatabaseSeeder::CHUNK_SIZE) as $chunk)
{
DB::table('productos')->insert($chunk);
}
self::log($archivo, self::CANASTA_CARGADA);
}
private static function obtenerIndiceDeHeader($csv){
@ -108,18 +102,4 @@ class CanastaHelper
}
return $result;
}
/**
* @param $nombre
* @param $descripcion
* @return void
*/
private static function log($nombre, $descripcion): void
{
$log = new CanastaLog([
'nombre' => $nombre,
'descripcion' => $descripcion,
]);
$log->save();
}
}

View File

@ -1,33 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CrearCargaDeCanastas extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('carga_de_canastas', function (Blueprint $table) {
$table->id();
$table->string('nombre');
$table->string('descripcion');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('carga_de_canastas');
}
}