58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
use App\Models\Log_general;
|
|
use App\Models\Log_historial;
|
|
use App\Models\User;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
|
|
class ShowLogHistorial extends Component
|
|
{
|
|
use WithPagination;
|
|
public $entradas;
|
|
|
|
public $buscar;
|
|
public $tipo;
|
|
public $filtro_fecha;
|
|
|
|
public $user_id;
|
|
|
|
public function render()
|
|
{
|
|
$query = Log_historial::query();
|
|
|
|
if ($this->buscar) {
|
|
$query->where(function ($query) {
|
|
$query->where('detalle', 'ILIKE', '%' . $this->buscar . '%')
|
|
->orWhereHas('user', function ($query) {
|
|
$query->where('name', 'ILIKE', '%' . $this->buscar . '%');
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
if ($this->tipo) {
|
|
$query->where('detalle', 'ILIKE', '%' . $this->tipo . '%');
|
|
}
|
|
|
|
if ($this->filtro_fecha) {
|
|
$query->whereDate('created_at', $this->filtro_fecha);
|
|
}
|
|
|
|
if ($this->user_id) {
|
|
$query->where('user_id', $this->user_id);
|
|
}
|
|
|
|
$logs = $query->orderBy('id', 'desc')->paginate($this->entradas);
|
|
|
|
$users = User::orderBy('name')->get();
|
|
|
|
return view('livewire.show-log-historial', [
|
|
'logs' => $logs,
|
|
'users' => $users
|
|
]);
|
|
}
|
|
}
|