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 @@
-
+
- + + + Distribuidores
- + {{-- tabla --}} -
+

Mejores distribuidores del mes

-
- -

{{$configuracion->mensaje_top}}

+
+ +

{{ $configuracion->mensaje_top }}

- + +
+ +
+ +
@@ -32,91 +58,88 @@ @endphp @foreach ($usuarios as $usuario) - @if($usuario->name == 'usuarioEliminado') - @else - - @php - $i++; - @endphp - - - - - - + @if ($usuario->name == 'usuarioEliminado') + @else + @php + $i++; + @endphp + + - - - @elseif ($i == 2) - - - - @elseif ($i == 3) - + - @elseif ($i == 4) - - @elseif ($i == 5) - + + + + - @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 - - - + @endif @endforeach
- - - - - {{ $usuario->name }}{{ $usuario->historiales_venta_count }}
- - @if ($i == 1) - - - {{$configuracion->premio_1}} - - - {{$configuracion->premio_2}} - - - {{$configuracion->premio_3}} - - - {{$configuracion->premio_4}} - - - {{$configuracion->premio_5}} - {{ $usuario->name }}{{ $usuario->historiales_venta_count }} - - {{$configuracion->premio_6}} - - - {{$configuracion->premio_7}} - - - {{$configuracion->premio_8}} - + + {{ $configuracion->premio_1 }} + + + {{ $configuracion->premio_2 }} + + + {{ $configuracion->premio_3 }} + + + {{ $configuracion->premio_4 }} + + + {{ $configuracion->premio_5 }} + + + {{ $configuracion->premio_6 }} + + + {{ $configuracion->premio_7 }} + + + {{ $configuracion->premio_8 }} + + + {{ $configuracion->premio_9 }} + + + {{ $configuracion->premio_10 }} + - - {{$configuracion->premio_9}} - - - {{$configuracion->premio_10}} -