update ajuste de premios

This commit is contained in:
Felipe
2025-01-02 11:49:06 -05:00
parent 551e017615
commit 5275bfced7
2 changed files with 13 additions and 9 deletions
+10 -8
View File
@@ -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
]);
+3 -1
View File
@@ -87,6 +87,8 @@ class ShowUsuarios extends Component
public $estadoTarifa = false;
public $estadoPromo = false;
public $entradas = false;
protected $rules = [
'nombre' => 'required',
'email' => 'required',
@@ -99,7 +101,7 @@ class ShowUsuarios extends Component
$consulta_tarifas = TarifaPromo::take(1);
$consulta_usuarios = User::where('name', 'LIKE', '%' . $this->buscar . '%')->orWhere('email', 'LIKE', '%' . $this->buscar . '%')->with('rol', 'saldo')->orderBy('id', 'DESC')->withCount('historiales_venta')->paginate(15);
$consulta_usuarios = User::where('name', 'LIKE', '%' . $this->buscar . '%')->orWhere('email', 'LIKE', '%' . $this->buscar . '%')->with('rol', 'saldo')->orderBy('id', 'DESC')->withCount('historiales_venta')->paginate($this->entradas);
if (!empty($this->buscar_servicio)) {
$this->consulta_tarifas = Tarifas::where('rol_id', $this->rol_usuario)->with([