Initial commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
use App\Models\Historiale;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ShowLogs extends Component
|
||||
{
|
||||
Use WithPagination;
|
||||
public $buscar;
|
||||
|
||||
public function render()
|
||||
{
|
||||
$fechaVencimiento = Carbon::now()->subDay(30);
|
||||
//dd($fechaVencimiento);
|
||||
$consulta_historial = Historiale::with('promocion', 'tarifa', 'vendedor','cuentas','cuentas_obsoletas')->whereDate('fecha_final','>', $fechaVencimiento)->orderBy('id', 'DESC')
|
||||
->when(!empty($this->buscar), function ($query) {
|
||||
$query->whereHas('cuentas', function ($subquery) {
|
||||
$subquery->where('correo', 'LIKE', '%' . $this->buscar . '%');
|
||||
})->orWhereHas('vendedor', function ($subquery) {
|
||||
$subquery->where('email', 'LIKE', '%' . $this->buscar . '%');
|
||||
});
|
||||
});
|
||||
// Limitar resultados a un máximo de 200
|
||||
$resultados= $consulta_historial->take(200)->paginate(20);
|
||||
|
||||
// Restablecer la paginación después de limitar los resultados
|
||||
$resultados->setCollection($resultados->getCollection()->values());
|
||||
|
||||
|
||||
//dd($consulta_historial);
|
||||
return view('livewire.show-logs',['logs'=>$resultados]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user