From 881ffdaaf99195abbe9cbb9fc9fc59d23a8c2cb7 Mon Sep 17 00:00:00 2001 From: Felipe Date: Thu, 27 Jul 2023 14:37:37 -0500 Subject: [PATCH] filtro por rol --- app/Http/Livewire/ShowUtilidades.php | 11 ++++++++- .../views/livewire/show-utilidades.blade.php | 23 +++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/app/Http/Livewire/ShowUtilidades.php b/app/Http/Livewire/ShowUtilidades.php index 45c4bfb..e41b976 100644 --- a/app/Http/Livewire/ShowUtilidades.php +++ b/app/Http/Livewire/ShowUtilidades.php @@ -3,15 +3,17 @@ namespace App\Http\Livewire; use App\Models\Historiale; +use App\Models\Role; use App\Models\Servicio; use Carbon\Carbon; use Livewire\Component; class ShowUtilidades extends Component { - public $promocion =1; + public $promocion = 1; public $servicio_id; + public $rol_id; public $selectedYear = null; public $selectedMonth = null; @@ -53,11 +55,18 @@ class ShowUtilidades extends Component $query = $query->whereNotNull('tarifa_id'); } + if ($this->rol_id) { + $query = $query->whereHas('vendedor', function ($q) { + $q->where('rol_id', $this->rol_id); + }); + } + $query = $query->where('estado', 'activo')->orderByDesc('created_at')->get(); return view('livewire.show-utilidades', [ 'historiales' => $query, 'servicios' => Servicio::where('estado', 'activo')->get(), + 'roles' => Role::get(), ]); } } diff --git a/resources/views/livewire/show-utilidades.blade.php b/resources/views/livewire/show-utilidades.blade.php index f349eb0..481dbdf 100644 --- a/resources/views/livewire/show-utilidades.blade.php +++ b/resources/views/livewire/show-utilidades.blade.php @@ -17,7 +17,7 @@ -
+
@@ -29,6 +29,18 @@ @endforeach
+ +
+ + +
+