diff --git a/app/Http/Livewire/ShowTop.php b/app/Http/Livewire/ShowTop.php index 0ba563c..219aceb 100644 --- a/app/Http/Livewire/ShowTop.php +++ b/app/Http/Livewire/ShowTop.php @@ -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, ]); } diff --git a/resources/views/livewire/show-top.blade.php b/resources/views/livewire/show-top.blade.php index 1cccbdc..6f8687b 100644 --- a/resources/views/livewire/show-top.blade.php +++ b/resources/views/livewire/show-top.blade.php @@ -1,22 +1,48 @@
Mejores distribuidores del mes
-{{$configuracion->mensaje_top}}
+{{ $configuracion->mensaje_top }}
| @@ -32,91 +58,88 @@ @endphp | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
-
-
-
-
- |
- {{ $usuario->name }} | - -{{ $usuario->historiales_venta_count }} | - + @if ($usuario->name == 'usuarioEliminado') + @else + @php + $i++; + @endphp +||||||||||||||||||||
| - - @if ($i == 1) - |
- |
-
-
- @elseif ($i == 2)
-
- |
-
-
- @elseif ($i == 3)
-
- |
+
- |
- @elseif ($i == 5)
-
- |
+
+ {{ $usuario->name }} | + +{{ $usuario->historiales_venta_count }} | - @elseif ($i == 6) -
- |
- @elseif ($i == 7)
-
- |
- @elseif ($i == 8)
-
- |
+ @if ($i == 1)
+
+ |
+ @elseif ($i == 2)
+
+ |
+ @elseif ($i == 3)
+
+ |
+ @elseif ($i == 4)
+
+ |
+ @elseif ($i == 5)
+
+ |
+ @elseif ($i == 6)
+
+ |
+ @elseif ($i == 7)
+
+ |
+ @elseif ($i == 8)
+
+ |
+ @elseif ($i == 9)
+
+ |
+ @elseif ($i == 10)
+
+ |
+ @endif
- @elseif ($i == 9)
-
- |
- @elseif ($i == 10)
-
- |
-
- @endif
-
-
-