This commit is contained in:
Laucha1312
2026-06-04 15:00:21 -03:00
parent ed94601e34
commit 47408d49fc
76 changed files with 0 additions and 7737 deletions
-30
View File
@@ -1,30 +0,0 @@
<?php
namespace App\AI\Tools;
use App\Models\Evento;
class CargarPuntajeTool
{
public function __invoke(
string $id_evento,
int $marcador_local,
int $marcador_visitante
): string {
$evento = Evento::find($id_evento);
if (!$evento) {
return json_encode(['error' => "No se encontró el partido con ID: {$id_evento}"]);
}
$evento->update([
'marcador_local' => $marcador_local,
'marcador_visitante' => $marcador_visitante,
]);
return json_encode([
'success' => true,
'mensaje' => "Puntaje actualizado: {$marcador_local} - {$marcador_visitante}",
]);
}
}
-43
View File
@@ -1,43 +0,0 @@
<?php
namespace App\AI\Tools;
use App\Models\Evento;
use Illuminate\Support\Str;
class CrearPartidoTool
{
public function __invoke(
int $id_equipo_local,
int $id_equipo_visitante,
string $fecha_evento,
string $hora_inicio,
string $hora_fin,
string $sede,
int $id_torneo,
?float $precio = null
): string {
try {
$evento = Evento::create([
'id_evento' => (string) Str::uuid(),
'id_equipo_local' => $id_equipo_local,
'id_equipo_visitante' => $id_equipo_visitante,
'fecha_evento' => $fecha_evento,
'hora_inicio' => str_contains($hora_inicio, ':') ? $hora_inicio . (strlen($hora_inicio) === 5 ? ':00' : '') : $hora_inicio,
'hora_fin' => str_contains($hora_fin, ':') ? $hora_fin . (strlen($hora_fin) === 5 ? ':00' : '') : $hora_fin,
'sede' => $sede,
'id_torneo' => $id_torneo,
'precio' => $precio ?? 0,
'fase' => Evento::FASE_REGULAR,
]);
return json_encode([
'success' => true,
'id_evento' => $evento->id_evento,
'mensaje' => "Partido creado correctamente. ID: {$evento->id_evento}",
]);
} catch (\Throwable $e) {
return json_encode(['error' => 'No se pudo crear el partido: ' . $e->getMessage()]);
}
}
}
-29
View File
@@ -1,29 +0,0 @@
<?php
namespace App\AI\Tools;
use App\Models\Noticia;
class EliminarNoticiaTool
{
public function __invoke(int $id_noticia): string
{
try {
$noticia = Noticia::find($id_noticia);
if (!$noticia) {
return json_encode(['error' => "No se encontró la noticia con ID: {$id_noticia}"]);
}
$titulo = $noticia->titulo;
$noticia->delete();
return json_encode([
'success' => true,
'mensaje' => "Noticia \"{$titulo}\" (ID {$id_noticia}) eliminada correctamente.",
]);
} catch (\Throwable $e) {
return json_encode(['error' => 'No se pudo eliminar la noticia: ' . $e->getMessage()]);
}
}
}
-28
View File
@@ -1,28 +0,0 @@
<?php
namespace App\AI\Tools;
use App\Models\Evento;
class EliminarPartidoTool
{
public function __invoke(string $id_evento): string
{
try {
$evento = Evento::find($id_evento);
if (!$evento) {
return json_encode(['error' => "No se encontró el partido con ID: {$id_evento}"]);
}
$evento->delete();
return json_encode([
'success' => true,
'mensaje' => "Partido {$id_evento} eliminado correctamente (soft delete).",
]);
} catch (\Throwable $e) {
return json_encode(['error' => 'No se pudo eliminar el partido: ' . $e->getMessage()]);
}
}
}
-33
View File
@@ -1,33 +0,0 @@
<?php
namespace App\AI\Tools;
use App\Models\Equipo;
class ListarEquiposTool
{
public function __invoke(?int $id_torneo = null, ?string $grupo = null): string
{
$query = Equipo::with('club');
if ($id_torneo !== null) {
$query->join('torneo_equipo', 'equipos.id_equipo', '=', 'torneo_equipo.id_equipo')
->where('torneo_equipo.id_torneo', $id_torneo);
if ($grupo !== null) {
$query->where('torneo_equipo.grupo', $grupo);
}
$query->select('equipos.id_equipo', 'equipos.categoria', 'equipos.division', 'equipos.id_club');
}
$equipos = $query->get()->map(fn($e) => [
'id_equipo' => $e->id_equipo,
'categoria' => $e->categoria,
'division' => $e->division,
'club' => $e->club?->nombre,
]);
return json_encode($equipos);
}
}
-40
View File
@@ -1,40 +0,0 @@
<?php
namespace App\AI\Tools;
use App\Models\Evento;
class ListarEventosTool
{
public function __invoke(
?string $fecha_desde = null,
?string $fecha_hasta = null,
?int $id_torneo = null
): string {
$query = Evento::with(['equipoLocal.club', 'equipoVisitante.club'])
->whereNull('deleted_at');
if ($fecha_desde) {
$query->whereDate('fecha_evento', '>=', $fecha_desde);
}
if ($fecha_hasta) {
$query->whereDate('fecha_evento', '<=', $fecha_hasta);
}
if ($id_torneo) {
$query->where('id_torneo', $id_torneo);
}
$eventos = $query->orderBy('fecha_evento')->get()->map(fn($e) => [
'id_evento' => $e->id_evento,
'fecha' => $e->fecha_evento?->format('Y-m-d'),
'hora' => $e->hora_inicio?->format('H:i'),
'local' => $e->equipoLocal?->club?->nombre,
'visitante' => $e->equipoVisitante?->club?->nombre,
'marcador_local' => $e->marcador_local,
'marcador_visitante' => $e->marcador_visitante,
'sede' => $e->sede,
]);
return json_encode($eventos);
}
}
-20
View File
@@ -1,20 +0,0 @@
<?php
namespace App\AI\Tools;
use App\Models\Torneo;
class ListarTorneosTool
{
public function __invoke(): string
{
$torneos = Torneo::orderByDesc('fecha_inicio')->get()->map(fn ($t) => [
'id_torneo' => $t->id,
'nombre' => $t->nombre,
'fecha_inicio' => $t->fecha_inicio?->format('Y-m-d'),
'fecha_fin' => $t->fecha_fin?->format('Y-m-d'),
]);
return json_encode($torneos);
}
}
-33
View File
@@ -1,33 +0,0 @@
<?php
namespace App\AI\Tools;
use App\Models\Noticia;
class RedactarNoticiaTool
{
public function __invoke(
string $titulo,
string $contenido,
?int $id_torneo = null,
?string $categoria = null
): string {
try {
$noticia = Noticia::create([
'titulo' => $titulo,
'contenido' => $contenido,
'fecha' => now(),
'id_torneo' => $id_torneo,
'categoria' => $categoria,
]);
return json_encode([
'success' => true,
'id_noticia' => $noticia->id,
'mensaje' => "Noticia \"{$titulo}\" creada correctamente.",
]);
} catch (\Throwable $e) {
return json_encode(['error' => 'No se pudo crear la noticia: ' . $e->getMessage()]);
}
}
}