cconsulta premios
This commit is contained in:
@@ -39,6 +39,7 @@ class ShowTop extends Component
|
|||||||
->limit(10)
|
->limit(10)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|
||||||
$consultaPremioEntregado = PremioEntregado::where('fecha', $monthYear)
|
$consultaPremioEntregado = PremioEntregado::where('fecha', $monthYear)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
@@ -51,18 +52,25 @@ class ShowTop extends Component
|
|||||||
|
|
||||||
public function entregarPremio()
|
public function entregarPremio()
|
||||||
{
|
{
|
||||||
|
$currentYear = date('Y');
|
||||||
|
|
||||||
$monthYear = date('m-Y', strtotime('last month'));
|
$monthYear = date('m-Y', strtotime('last month'));
|
||||||
$month = date('m', strtotime('last month'));
|
$month = date('m', strtotime('last month'));
|
||||||
$rangos = ['primero', 'segundo', 'tercero', 'cuarto', 'quinto', 'sexto', 'séptimo', 'octavo', 'noveno', 'décimo'];
|
$rangos = ['primero', 'segundo', 'tercero', 'cuarto', 'quinto', 'sexto', 'séptimo', 'octavo', 'noveno', 'décimo'];
|
||||||
|
|
||||||
|
|
||||||
$top_vendedores = User::with(['historiales_venta' => function ($query) use ($month) {
|
$top_vendedores = User::with(['historiales_venta' => function ($query) use ($month, $currentYear) {
|
||||||
$query->whereMonth('fecha_inicio', $month);
|
$query->whereMonth('fecha_inicio', $month)
|
||||||
|
->whereYear('fecha_inicio', $currentYear)
|
||||||
|
->where('estado', 'activo');
|
||||||
}])
|
}])
|
||||||
->withCount(['historiales_venta' => function ($query) use ($month) {
|
->withCount(['historiales_venta' => function ($query) use ($month, $currentYear) {
|
||||||
$query->whereMonth('fecha_inicio', $month);
|
$query->whereMonth('fecha_inicio', $month)
|
||||||
}])->orderBy('historiales_venta_count', 'desc')->take(10)->get();
|
->whereYear('fecha_inicio', $currentYear);
|
||||||
|
}])
|
||||||
|
->orderBy('historiales_venta_count', 'desc')
|
||||||
|
->limit(10)
|
||||||
|
->get();
|
||||||
|
|
||||||
foreach ($top_vendedores as $index => $vendedor) {
|
foreach ($top_vendedores as $index => $vendedor) {
|
||||||
$premio = $this->configuracion->{'premio_' . ($index + 1)};
|
$premio = $this->configuracion->{'premio_' . ($index + 1)};
|
||||||
|
|||||||
Reference in New Issue
Block a user