HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/8.0.30
System: Linux multiplicar 3.10.0-1160.102.1.el7.x86_64 #1 SMP Tue Oct 17 15:42:21 UTC 2023 x86_64
User: root (0)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /var/www/html/xfacil.desafio.com.py/app/Http/Livewire/Ranking.php
<?php

namespace App\Http\Livewire;

use Livewire\Component;
use App\Models\Equipo;
use App\Models\Matricula;
use Carbon\Carbon;
use Auth;
use DB;

class Ranking extends Component{

    public $fecha_inicio,$fecha_fin;

	public function mount(){
		$this->fecha_inicio=Carbon::now()->format('Y')."-01-01";
		$this->fecha_fin=Carbon::now()->format('Y-m-d');
	}

    public function render(){

    	$matricula=Matricula::where('usuario_id',Auth::id())->first();

    	$equipo=Equipo::where('id',$matricula->equipo_id)->first();

        if($this->fecha_inicio && $this->fecha_fin){
            $equipos = Equipo::where('id', '!=', 30)
                ->where('id', '!=', 37)
                ->where('estado', 1)
                ->whereDate('created_at', '>=', Carbon::parse($this->fecha_inicio)->toDateString())
                ->whereDate('created_at', '<=', Carbon::parse($this->fecha_fin)->toDateString())
                ->where('nivel', $equipo->nivel)
                ->orderBy(DB::raw("CAST(`puntos` AS SIGNED) + CAST(`puntos_extras` AS SIGNED)"), 'desc')
                ->get();
        } else {
            $equipos = Equipo::where('id', '!=', 30)
                ->where('id', '!=', 37)
                ->where('estado', 1)
                ->where('nivel', $equipo->nivel)
                ->orderBy(DB::raw("CAST(`puntos` AS SIGNED) + CAST(`puntos_extras` AS SIGNED)"), 'desc')
                ->get();
        }
        

        return view('livewire.ranking',["equipos" => $equipos]);
    }
}