cconsulta premios
This commit is contained in:
@@ -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)};
|
||||
|
||||
Reference in New Issue
Block a user