ver el mes pasado

This commit is contained in:
Felipe
2023-08-01 14:28:51 -05:00
parent 4759600e1e
commit f435dd2f12
2 changed files with 127 additions and 101 deletions
+19 -16
View File
@@ -8,27 +8,30 @@ use Livewire\Component;
use Jantinnerezo\LivewireAlert\LivewireAlert;
class ShowTop extends Component
{ public $configuracion;
{
public $configuracion;
public $showLastMonth = false;
use LivewireAlert;
public function render()
{
$this->configuracion = Configuracione::orderby('id','desc')->first();
$consulta_ventas = User::with(['historiales_venta' => function ($query) {
$query->whereMonth('fecha_inicio', date('m'));
{
$this->configuracion = Configuracione::orderby('id', 'desc')->first();
$month = $this->showLastMonth ? date('m', strtotime('last month')) : date('m');
$consulta_ventas = User::with(['historiales_venta' => function ($query) use ($month) {
$query->whereMonth('fecha_inicio', $month);
}])
->withCount(['historiales_venta' => function ($query) {
$query->whereMonth('fecha_inicio', date('m'));
}])
->orderBy('historiales_venta_count', 'desc')
->limit(10)
->get();
->withCount(['historiales_venta' => function ($query) use ($month) {
$query->whereMonth('fecha_inicio', $month);
}])
->orderBy('historiales_venta_count', 'desc')
->limit(10)
->get();
//dd($consulta_ventas);
return view('livewire.show-top',[
return view('livewire.show-top', [
'usuarios' => $consulta_ventas,
]);
}