diff --git a/app/Http/Livewire/Bell.php b/app/Http/Livewire/Bell.php index 02f28f7..197bc6a 100755 --- a/app/Http/Livewire/Bell.php +++ b/app/Http/Livewire/Bell.php @@ -2,6 +2,7 @@ namespace App\Http\Livewire; +use App\Models\Log_general; use App\Models\Notificacion; use App\Models\PremioEntregado; use App\Models\Saldo; @@ -74,6 +75,11 @@ class Bell extends Component } } + Log_general::create([ + 'user_id' => Auth::user()->id, + 'detalle' => 'El usuario ' . Auth::user()->name . ' - ' . Auth::user()->email . ' ha reclamado el premio de $' . $notificacion->premio + ]); + $this->reclamandoPremio = false; $this->alert('success', 'Haz reclamado el premio correctamente', [ diff --git a/app/Http/Livewire/ShowTop.php b/app/Http/Livewire/ShowTop.php index bb610d2..630c3cb 100755 --- a/app/Http/Livewire/ShowTop.php +++ b/app/Http/Livewire/ShowTop.php @@ -3,6 +3,7 @@ namespace App\Http\Livewire; use App\Models\Configuracione; +use App\Models\Log_general; use App\Models\Notificacion; use App\Models\PremioEntregado; use App\Models\User; @@ -18,35 +19,34 @@ class ShowTop extends Component use LivewireAlert; public function render() -{ - $this->configuracion = Configuracione::orderby('id', 'desc')->first(); + { + $this->configuracion = Configuracione::orderby('id', 'desc')->first(); - $currentYear = date('Y'); - $monthYear = date('m-Y', strtotime('last month')); - $month = $this->showLastMonth ? date('m', strtotime('last month')) : date('m'); + $currentYear = date('Y'); + $monthYear = date('m-Y', strtotime('last month')); + $month = $this->showLastMonth ? date('m', strtotime('last month')) : date('m'); - $consulta_ventas = 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, $currentYear) { - $query->whereMonth('fecha_inicio', $month) - ->whereYear('fecha_inicio', $currentYear); - }]) - ->orderBy('historiales_venta_count', 'desc') - ->limit(10) - ->get(); + $consulta_ventas = 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, $currentYear) { + $query->whereMonth('fecha_inicio', $month) + ->whereYear('fecha_inicio', $currentYear); + }]) + ->orderBy('historiales_venta_count', 'desc') + ->limit(10) + ->get(); - $consultaPremioEntregado = PremioEntregado::whereYear('fecha', $currentYear) - ->where('fecha', $monthYear) - ->first(); + $consultaPremioEntregado = PremioEntregado::where('fecha', $monthYear) + ->first(); - return view('livewire.show-top', [ - 'usuarios' => $consulta_ventas, - 'consultaPremioEntregado' => $consultaPremioEntregado - ]); -} + return view('livewire.show-top', [ + 'usuarios' => $consulta_ventas, + 'consultaPremioEntregado' => $consultaPremioEntregado + ]); + } public function entregarPremio() @@ -75,8 +75,13 @@ class ShowTop extends Component $notificacion->descripcion = 'Quedaste ' . $rangos[$index] . ' en el #Top10MejoresDistribuidores del mes de ' . date('M', strtotime('last month')); $notificacion->estado = 1; $notificacion->todos = 0; - $notificacion->premio = str_replace('.','',str_replace('$', '', $premio)); + $notificacion->premio = str_replace('.', '', str_replace('$', '', $premio)); $notificacion->save(); + + Log_general::create([ + 'user_id' => Auth::user()->id, + 'detalle' => 'El usuario ' . Auth::user()->name . ' ha entregado el premio ' . $premio . ' para el usuario: ' . $vendedor->name . ' - ' . $vendedor->email + ]); } PremioEntregado::create([ @@ -88,6 +93,5 @@ class ShowTop extends Component $this->alert('success', 'Premios entregados correctamente', [ 'position' => 'top' ]); - } } diff --git a/resources/views/livewire/show-top.blade.php b/resources/views/livewire/show-top.blade.php index ec46041..545da4c 100755 --- a/resources/views/livewire/show-top.blade.php +++ b/resources/views/livewire/show-top.blade.php @@ -3,17 +3,19 @@
- + Distribuidores
{{-- tabla --}} -
+

Mejores distribuidores del mes

- +

{{ $configuracion->mensaje_top }}

@@ -33,18 +35,23 @@ @if (Auth::user()->rol->nombre == 'super') -
- Entregar premios de {{ Carbon\Carbon::now()->subMonth()->format('M') }} - @if ($consultaPremioEntregado) - - Los premios del mes de {{ Carbon\Carbon::now()->subMonth()->format('M') }} ya fueron entregados - - @endif -
+
+ Entregar premios de + {{ Carbon\Carbon::now()->subMonth()->format('M') }} + @if ($consultaPremioEntregado) + + Los premios del mes de {{ Carbon\Carbon::now()->subMonth()->format('M') }} ya fueron + entregados + + @endif +
@endif
- +