Enter daily data in MYSQL with php

0

I am working on an app that receives 10 to 13 data and they are saved in a table of my BD, I need to add that data and that sum is saved in another field of the table, I am using Laravel 5.5.

this is the driver:

public function show($id)
{
//fechas ingresadas de otra vista
   $fecha1 = DB::table('fechas')->pluck('fecha_inicio')->all();
   $fecha2 = DB::table('fechas')->pluck('fecha_fin')->all();
//fechas convertidas a string       
   $fecha1 = implode($fecha1);
   $fecha2 = implode($fecha2);
//las vuelvo string de carbon
   $primer_dia = (new Carbon($fecha1))->toDateString();
   $ultimo_dia = (new Carbon($fecha2))->toDateString();
//query
   $consumes = consume::where('user_id', $id)
    ->whereBetween('created_at',[$primer_dia,$ultimo_dia])
    ->get();
//vista
   return view('user.consumo.show', [
    'consumes'=>$consumes,
    'fecha1' =>$fecha1,
    'fecha2' =>$fecha2,
   ]);
}

Is it done by counting or by date? I receive suggestions.

    
asked by Freddy Forero 27.07.2018 в 23:42
source

1 answer

0

I would recommend that you work on a task scheduled in laravel, it can be executed automatically every day at the time you schedule it.

I leave the documentation here: Task Scheduling

I hope it helps you.

    
answered by 01.08.2018 в 14:08