update ajuste de premios
This commit is contained in:
@@ -41,6 +41,7 @@ class ShowTop extends Component
|
||||
->get();
|
||||
|
||||
|
||||
//
|
||||
$consultaPremioEntregado = PremioEntregado::where('fecha', $monthYear)
|
||||
->first();
|
||||
|
||||
@@ -53,21 +54,22 @@ class ShowTop extends Component
|
||||
|
||||
public function entregarPremio()
|
||||
{
|
||||
$currentYear = date('Y');
|
||||
$previousMonthDate = strtotime('first day of last month');
|
||||
$month = date('m', $previousMonthDate);
|
||||
$year = date('Y', $previousMonthDate);
|
||||
|
||||
|
||||
$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, $currentYear) {
|
||||
$top_vendedores = User::with(['historiales_venta' => function ($query) use ($month, $year) {
|
||||
$query->whereMonth('fecha_inicio', $month)
|
||||
->whereYear('fecha_inicio', $currentYear)
|
||||
->whereYear('fecha_inicio', $year)
|
||||
->where('estado', 'activo');
|
||||
}])
|
||||
->withCount(['historiales_venta' => function ($query) use ($month, $currentYear) {
|
||||
->withCount(['historiales_venta' => function ($query) use ($month, $year) {
|
||||
$query->whereMonth('fecha_inicio', $month)
|
||||
->whereYear('fecha_inicio', $currentYear)
|
||||
->whereYear('fecha_inicio', $year)
|
||||
->where('estado', 'activo');
|
||||
}])
|
||||
->orderBy('historiales_venta_count', 'desc')
|
||||
@@ -96,7 +98,7 @@ class ShowTop extends Component
|
||||
|
||||
PremioEntregado::create([
|
||||
'user_id' => Auth::user()->id,
|
||||
'fecha' => $monthYear,
|
||||
'fecha' => $year,
|
||||
'entregado' => 1
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user