Initial commit: Horux Strategy Platform
- Laravel 11 backend with API REST - React 18 + TypeScript + Vite frontend - Multi-parser architecture for accounting systems (CONTPAQi, Aspel, SAP) - 27+ financial metrics calculation - PDF report generation with Browsershot - Complete documentation (10 documents) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
62
backend/app/Http/Controllers/Admin/GiroController.php
Normal file
62
backend/app/Http/Controllers/Admin/GiroController.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Giro;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class GiroController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return response()->json(Giro::all());
|
||||
}
|
||||
|
||||
public function activos(): JsonResponse
|
||||
{
|
||||
return response()->json(Giro::where('activo', true)->get());
|
||||
}
|
||||
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'nombre' => 'required|string|max:255|unique:giros,nombre',
|
||||
'activo' => 'boolean',
|
||||
]);
|
||||
|
||||
$giro = Giro::create($validated);
|
||||
|
||||
return response()->json($giro, 201);
|
||||
}
|
||||
|
||||
public function show(Giro $giro): JsonResponse
|
||||
{
|
||||
return response()->json($giro);
|
||||
}
|
||||
|
||||
public function update(Request $request, Giro $giro): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'nombre' => 'string|max:255|unique:giros,nombre,' . $giro->id,
|
||||
'activo' => 'boolean',
|
||||
]);
|
||||
|
||||
$giro->update($validated);
|
||||
|
||||
return response()->json($giro);
|
||||
}
|
||||
|
||||
public function destroy(Giro $giro): JsonResponse
|
||||
{
|
||||
if ($giro->clientes()->exists()) {
|
||||
return response()->json([
|
||||
'message' => 'No se puede eliminar un giro con clientes asociados'
|
||||
], 422);
|
||||
}
|
||||
|
||||
$giro->delete();
|
||||
return response()->json(['message' => 'Giro eliminado']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user