filtro por rol

This commit is contained in:
Felipe
2023-07-27 14:37:37 -05:00
parent c35847f86c
commit 881ffdaaf9
2 changed files with 29 additions and 5 deletions
+10 -1
View File
@@ -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(),
]);
}
}