diff --git a/app/Http/Controllers/CapacidadController.php b/app/Http/Controllers/CapacidadController.php new file mode 100644 index 0000000..e4caf50 --- /dev/null +++ b/app/Http/Controllers/CapacidadController.php @@ -0,0 +1,92 @@ +busqueda; + + if($busqueda) { + $capacidades = Capacidad::where('cantidad', 'LIKE', "%{$busqueda}%")->get(); + + if($capacidades->count() == 0) { + return redirect()->route('capacidades.index') + ->with('error', 'No existe ninguna capacidad con la cantidad "' . $busqueda . '". Por favor, inténtalo de nuevo.'); + } + + if($capacidades->count() == 1) { + $capacidad = $capacidades->first(); + return redirect()->route('capacidades.edit', $capacidad->id); + } + + return view('capacidades', ["capacidades" => $capacidades]); + } + + $capacidades = Capacidad::all(); + return view('capacidades', ["capacidades" => $capacidades]); + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + return view('capacidadesCrearEditar'); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + $capacidad = new Capacidad($request->all()); + $capacidad->save(); + return redirect()->route('capacidades.index')->with('success', 'Capacidad creada exitosamente.'); + } + + /** + * Display the specified resource. + */ + public function show(Capacidad $capacidad) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit($id) + { + $capacidad = Capacidad::find($id); + return view('capacidadesCrearEditar', ['capacidad' => $capacidad]); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, $id) + { + $capacidad = Capacidad::find($id); + $capacidad->fill($request->all()); + $capacidad->save(); + return redirect()->route('capacidades.index')->with('success', 'Capacidad actualizada exitosamente.'); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy($id) + { + $capacidad = Capacidad::find($id); + $capacidad->delete(); + return redirect()->route('capacidades.index')->with('success', 'Capacidad eliminada exitosamente.'); + } +} diff --git a/app/Models/Capacidad.php b/app/Models/Capacidad.php new file mode 100644 index 0000000..f495253 --- /dev/null +++ b/app/Models/Capacidad.php @@ -0,0 +1,13 @@ + + */ +class CapacidadFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + + // + ]; + } +} diff --git a/database/migrations/2025_03_13_133629_create_capacidads_table.php b/database/migrations/2025_03_13_133629_create_capacidads_table.php new file mode 100644 index 0000000..87eb55b --- /dev/null +++ b/database/migrations/2025_03_13_133629_create_capacidads_table.php @@ -0,0 +1,28 @@ +id(); + $table->integer('capacidad')->unique(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('capacidades'); + } +}; diff --git a/database/seeders/CapacidadSeeder.php b/database/seeders/CapacidadSeeder.php new file mode 100644 index 0000000..17537a5 --- /dev/null +++ b/database/seeders/CapacidadSeeder.php @@ -0,0 +1,21 @@ + 100, + ]); + + // + } +} diff --git a/resources/views/capacidades.blade.php b/resources/views/capacidades.blade.php new file mode 100644 index 0000000..3936eed --- /dev/null +++ b/resources/views/capacidades.blade.php @@ -0,0 +1,66 @@ +@extends('layouts.dashboard') + +@section('content') +
+ @if(session('success')) + + @endif + + @if(session('error')) + + @endif + +
+
+

Gestión de Capacidades

+ + + Agregar + +
+ +
+ + + + + + + + + + @foreach($capacidades as $capacidad) + + + + + + @endforeach + +
IDCantidadAcciones
{{ $capacidad->id }}{{ $capacidad->cantidad }} +
+ + + +
+ @csrf + @method('DELETE') + +
+
+
+
+
+
+@endsection diff --git a/resources/views/capacidadesCrearEditar.blade.php b/resources/views/capacidadesCrearEditar.blade.php new file mode 100644 index 0000000..aebf05e --- /dev/null +++ b/resources/views/capacidadesCrearEditar.blade.php @@ -0,0 +1,132 @@ +@extends('layouts.dashboard') + +@section('content') +
+
+
+
+ +
+

+ {{ isset($capacidad) ? 'Editar Capacidad' : 'Nueva Capacidad' }} +

+
+ +
+
+ + + @if($errors->any()) +
+
+ +
+
    + @foreach($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+
+
+ @endif + + +
+ @csrf + @if(isset($capacidad)) + @method('PUT') + @endif + +
+ +
+ +
+
+ +
+ +
+ @error('cantidad') +

{{ $message }}

+ @enderror +
+ + +
+ + Cancelar + + +
+
+
+
+
+
+
+ + +@endsection diff --git a/resources/views/docentesCrearEditar.blade.php b/resources/views/docentesCrearEditar.blade.php index 277c60c..f5d33f3 100644 --- a/resources/views/docentesCrearEditar.blade.php +++ b/resources/views/docentesCrearEditar.blade.php @@ -31,7 +31,14 @@
- +
diff --git a/resources/views/layouts/dashboard.blade.php b/resources/views/layouts/dashboard.blade.php index eed6e09..dff585b 100644 --- a/resources/views/layouts/dashboard.blade.php +++ b/resources/views/layouts/dashboard.blade.php @@ -113,8 +113,8 @@
  • - - + + Capacidad
  • @@ -186,10 +186,10 @@
    diff --git a/routes/web.php b/routes/web.php index f8d0108..ee8a9ee 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6,7 +6,11 @@ use App\Http\Controllers\HomeController; use App\Http\Controllers\MarcaController; use App\Http\Controllers\DocentesController; use App\Http\Controllers\TiposVeiculosController; + use App\Http\Controllers\TiposLicenciasController; + +use App\Http\Controllers\CapacidadController; + /* |-------------------------------------------------------------------------- | Web Routes @@ -27,8 +31,13 @@ Auth::routes(['register'=>true,'reset'=>false]); Route::resource('marca', MarcaController::class); Route::resource('docentes', DocentesController::class); Route::resource('vehiculos', TiposVeiculosController::class); + + Route::resource('tiposLicencias', TiposLicenciasController::class); +Route::resource('capacidades', CapacidadController::class); + + // Rutas protegidas que requieren autenticación Route::middleware(['auth'])->group(function () {