Ahora si :)))))))))))))))))

This commit is contained in:
Laucha1312
2026-06-04 15:10:18 -03:00
parent 47408d49fc
commit 1a8c01ae45
167 changed files with 15870 additions and 0 deletions
@@ -0,0 +1,70 @@
<?php
namespace App\Http\Controllers;
use App\Models\Promocion;
use Illuminate\Http\Request;
class PromocionController extends Controller
{
public function index(Request $request)
{
$promociones = Promocion::all();
if ($request->expectsJson()) {
return response()->json($promociones);
}
$categorias = $promociones->pluck('categoria')->filter()->unique()->values();
return view('promos.index', compact('promociones', 'categorias'));
}
public function show($id)
{
$promocion = Promocion::with('promoQrs')->findOrFail($id);
return response()->json($promocion);
}
public function store(Request $request)
{
$data = $request->validate([
'nombre' => 'required|string|max:100',
'direccion' => 'required|string|max:150',
'lat' => 'nullable|numeric',
'lng' => 'nullable|numeric',
'contacto' => 'nullable|string|max:100',
'descripcion' => 'nullable',
'descripcion_lugar' => 'nullable',
'categoria' => 'nullable|string|max:50',
'imagen' => 'nullable|string|max:200',
]);
$promocion = Promocion::create($data);
return response()->json($promocion, 201);
}
public function update(Request $request, $id)
{
$promocion = Promocion::findOrFail($id);
$data = $request->validate([
'nombre' => 'sometimes|string|max:100',
'direccion' => 'sometimes|string|max:150',
'lat' => 'nullable|numeric',
'lng' => 'nullable|numeric',
'contacto' => 'nullable|string|max:100',
'descripcion' => 'nullable',
'descripcion_lugar' => 'nullable',
'categoria' => 'nullable|string|max:50',
'imagen' => 'nullable|string|max:200',
]);
$promocion->update($data);
return response()->json($promocion);
}
public function destroy($id)
{
$promocion = Promocion::findOrFail($id);
$promocion->delete();
return response()->json(null, 204);
}
}