cconsulta premios

This commit is contained in:
Felipe
2024-07-03 13:23:04 -05:00
parent 58fef053d9
commit 020bf656c3
+14 -6
View File
@@ -39,6 +39,7 @@ class ShowTop extends Component
->limit(10)
->get();
$consultaPremioEntregado = PremioEntregado::where('fecha', $monthYear)
->first();
@@ -51,18 +52,25 @@ class ShowTop extends Component
public function entregarPremio()
{
$currentYear = date('Y');
$monthYear = date('m-Y', strtotime('last month'));
$month = date('m', strtotime('last month'));
$rangos = ['primero', 'segundo', 'tercero', 'cuarto', 'quinto', 'sexto', 'séptimo', 'octavo', 'noveno', 'décimo'];
$top_vendedores = User::with(['historiales_venta' => function ($query) use ($month) {
$query->whereMonth('fecha_inicio', $month);
$top_vendedores = User::with(['historiales_venta' => function ($query) use ($month, $currentYear) {
$query->whereMonth('fecha_inicio', $month)
->whereYear('fecha_inicio', $currentYear)
->where('estado', 'activo');
}])
->withCount(['historiales_venta' => function ($query) use ($month) {
$query->whereMonth('fecha_inicio', $month);
}])->orderBy('historiales_venta_count', 'desc')->take(10)->get();
->withCount(['historiales_venta' => function ($query) use ($month, $currentYear) {
$query->whereMonth('fecha_inicio', $month)
->whereYear('fecha_inicio', $currentYear);
}])
->orderBy('historiales_venta_count', 'desc')
->limit(10)
->get();
foreach ($top_vendedores as $index => $vendedor) {
$premio = $this->configuracion->{'premio_' . ($index + 1)};