Files
sirpremiumv2/app/Http/Livewire/ShowTop.php
T
2023-11-07 22:43:10 +00:00

39 lines
1.0 KiB
PHP
Executable File

<?php
namespace App\Http\Livewire;
use App\Models\Configuracione;
use App\Models\User;
use Livewire\Component;
use Jantinnerezo\LivewireAlert\LivewireAlert;
class ShowTop extends Component
{
public $configuracion;
public $showLastMonth = false;
use LivewireAlert;
public function render()
{
$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) use ($month) {
$query->whereMonth('fecha_inicio', $month);
}])
->orderBy('historiales_venta_count', 'desc')
->limit(10)
->get();
//dd($consulta_ventas);
return view('livewire.show-top', [
'usuarios' => $consulta_ventas,
]);
}
}