65 lines
1.5 KiB
PHP
65 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
use App\Models\Historial_cuenta;
|
|
use Livewire\Component;
|
|
use Jantinnerezo\LivewireAlert\LivewireAlert;
|
|
use Livewire\WithPagination;
|
|
|
|
class ShowMantenimiento extends Component
|
|
{
|
|
use WithPagination;
|
|
use LivewireAlert;
|
|
|
|
public $entradas = 10;
|
|
public $delete_1 = [];
|
|
|
|
public $cont = [];
|
|
|
|
public function render()
|
|
{
|
|
$historialesConEstadoPendiente = Historial_cuenta::whereHas('historial', function ($query) {
|
|
$query->where('estado', 'pendiente');
|
|
})->paginate($this->entradas);
|
|
|
|
$this->cont = $historialesConEstadoPendiente->toArray();
|
|
|
|
return view('livewire.show-mantenimiento', [
|
|
'historiales' => $historialesConEstadoPendiente
|
|
]);
|
|
}
|
|
|
|
public function seleccionarTodos()
|
|
{
|
|
if (count($this->delete_1) == 0) {
|
|
$this->delete_1 = array_column($this->cont['data'], 'id');
|
|
} else {
|
|
$this->delete_1 = [];
|
|
}
|
|
|
|
//dd($this->delete_1);
|
|
}
|
|
|
|
public function eliminarCuentasSinHistorial()
|
|
{
|
|
Historial_cuenta::whereNull('historial_id')->delete();
|
|
|
|
$this->alert('success', 'Historiales vacios eliminados correctamente!', [
|
|
'position' => 'top'
|
|
]);
|
|
}
|
|
|
|
|
|
public function eliminarCuentas()
|
|
{
|
|
Historial_cuenta::whereIn('id', $this->delete_1)->delete();
|
|
|
|
$this->delete_1 = [];
|
|
|
|
$this->alert('success', 'Historiales eliminados correctamente!', [
|
|
'position' => 'top'
|
|
]);
|
|
}
|
|
}
|