diff --git a/BD/Login - Ultima clase primer cuatrimestre.pdf b/BD/Login - Ultima clase primer cuatrimestre.pdf new file mode 100644 index 0000000..f0458f8 Binary files /dev/null and b/BD/Login - Ultima clase primer cuatrimestre.pdf differ diff --git a/BD/clase boostrap y validacion laravel.pdf b/BD/clase boostrap y validacion laravel.pdf new file mode 100644 index 0000000..b432755 Binary files /dev/null and b/BD/clase boostrap y validacion laravel.pdf differ diff --git a/app/Http/Controllers/CategoriasController.php b/app/Http/Controllers/CategoriasController.php index f9790d0..7573ce1 100644 --- a/app/Http/Controllers/CategoriasController.php +++ b/app/Http/Controllers/CategoriasController.php @@ -5,7 +5,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Http\RedirectResponse; use App\Models\Categorias; - +use App\Http\Requests\UpdatedCategoriaRequest; class CategoriasController extends Controller { @@ -35,6 +35,7 @@ class CategoriasController extends Controller public function destroy(Request $request, $id){ $categorias = Categorias::findOrfail($id); $categorias->delete(); + $request->session()->flash('mensaje-success', 'La categoría fue eliminada.'); return redirect('/categorias'); } @@ -45,6 +46,18 @@ class CategoriasController extends Controller public function store(Request $request){ + $request->validate([ + 'descripcion' => 'required|max:20|', + 'nombre' => 'required|unique:categorias,nombre', + ], + [ + 'descripcion.required' => 'el campo descripcion debe ser requerido', + 'descripcion.max' => 'el campo descripcion debe contener maximo 10 caracteres', + 'nombre.required' => 'el campo nombre es requerido', + 'nombre.unique' => 'ya existe una categoria con ese nombre' + ] + ); + $categorias = new Categorias(); $categorias->fill([ 'nombre' => $request->input('nombre'), @@ -73,6 +86,7 @@ class CategoriasController extends Controller public function restaurar(Request $request, $id){ $categorias = Categorias::withTrashed()->findOrfail($id); $categorias->restore(); + $request->session()->flash('mensaje-success', 'La categoría fue restaurada.'); return redirect('/categorias'); } diff --git a/resources/views/categorias/edit.blade.php b/resources/views/categorias/edit.blade.php index 9262316..bb512c9 100644 --- a/resources/views/categorias/edit.blade.php +++ b/resources/views/categorias/edit.blade.php @@ -1,35 +1,74 @@ - - - - - - Editar categoría - - +@extends('layouts.admin') +@section('contenido') -

Editar categoría

+ +
+ +
+

Editar Categoría

+
+
+
+
-
+ + @include('compartido.mensajes') + @include('compartido.errores') +
+
+
+ + + @csrf - @method('PUT') + @method('PUT') -
-
- + +
+ + +
+ + + + +
+ +
+ + +
-
-
- -
- -
- - Volver al listado + +
+
+ + +
+
+ + Salir +
- - +@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/categorias/editPlano.blade.php b/resources/views/categorias/editPlano.blade.php new file mode 100644 index 0000000..9262316 --- /dev/null +++ b/resources/views/categorias/editPlano.blade.php @@ -0,0 +1,35 @@ + + + + + + Editar categoría + + + +

Editar categoría

+ +
+ @csrf + @method('PUT') + +
+
+ +
+ +
+
+ +
+ +
+ + Volver al listado +
+
+ + + diff --git a/resources/views/categorias/index.blade.php b/resources/views/categorias/index.blade.php index de757b8..7a4500f 100644 --- a/resources/views/categorias/index.blade.php +++ b/resources/views/categorias/index.blade.php @@ -1,50 +1,128 @@ - - - - Categorías - - -

- Nueva categoría -

- +
- - +
+
+ + + @include('compartido.mensajes') + @include('compartido.errores') + + +
+ + + + + + + + + + + + + @foreach($categorias as $cat) + + + + + + + @endforeach + +
IdNombreDescripcionAcciones
{{ $cat->id_categoria }}{{ $cat->nombre }}{{ $cat->descripcion }} + + @if($cat->deleted_at == null) +
+ @csrf + @method('DELETE') + + + + + + + + + + + + + +
+ @else +
+ @csrf + @method('PUT') + + + +
+ + @endif +
+
+ +
+
+ +@endsection +@push('styles') + +@endpush +@push('scripts') + +@endpush diff --git a/resources/views/categorias/indexPlano.blade.php b/resources/views/categorias/indexPlano.blade.php new file mode 100644 index 0000000..de757b8 --- /dev/null +++ b/resources/views/categorias/indexPlano.blade.php @@ -0,0 +1,50 @@ + + + + Categorías + + +

+ Nueva categoría +

+ + + + diff --git a/resources/views/categorias/new.blade.php b/resources/views/categorias/new.blade.php index c701f8c..114bf40 100644 --- a/resources/views/categorias/new.blade.php +++ b/resources/views/categorias/new.blade.php @@ -1,32 +1,70 @@ - - - - - - Nueva categoría - - +@extends('layouts.admin') +@section ('contenido') -

Nueva categoría

+ +
+ +
+

Nueva Categoría

+
+
+
+
-
- @csrf + + @include('compartido.mensajes') + @include('compartido.errores') +
+
+
-
-
- -
+ + + @csrf + + +
+ +
+ + + + +
-
-
- -
+
+ + +
+
-
- - Volver al listado -
+ + +
+
+ + +
+
+ + Salir +
+
- - \ No newline at end of file +@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/categorias/newPlano.blade.php b/resources/views/categorias/newPlano.blade.php new file mode 100644 index 0000000..c701f8c --- /dev/null +++ b/resources/views/categorias/newPlano.blade.php @@ -0,0 +1,32 @@ + + + + + + Nueva categoría + + + +

Nueva categoría

+ +
+ @csrf + +
+
+ +
+ +
+
+ +
+ +
+ + Volver al listado +
+
+ + + \ No newline at end of file diff --git a/resources/views/categorias/show.blade.php b/resources/views/categorias/show.blade.php index 8d49995..8d145ee 100644 --- a/resources/views/categorias/show.blade.php +++ b/resources/views/categorias/show.blade.php @@ -1,31 +1,28 @@ - - - - - - Ver categoría - - +@extends('layouts.admin') +@section ('contenido') +
+
+

Ver Categoría

+
+
+
+
+
+
+ + +
+
+ + +
+
-

Ver categoría

+ +
+
+ Salir +
+
- - -
-
- -
- -
-
- -
- -
- Volver al listado -
- - - +@endsection \ No newline at end of file diff --git a/resources/views/categorias/showPlano.blade.php b/resources/views/categorias/showPlano.blade.php new file mode 100644 index 0000000..8d49995 --- /dev/null +++ b/resources/views/categorias/showPlano.blade.php @@ -0,0 +1,31 @@ + + + + + + Ver categoría + + + +

Ver categoría

+ + + +
+
+ +
+ +
+
+ +
+ +
+ Volver al listado +
+ + + diff --git a/resources/views/compartido/errores.blade.php b/resources/views/compartido/errores.blade.php new file mode 100644 index 0000000..16ff22c --- /dev/null +++ b/resources/views/compartido/errores.blade.php @@ -0,0 +1,9 @@ +@if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+@endif \ No newline at end of file diff --git a/resources/views/compartido/mensajes.blade.php b/resources/views/compartido/mensajes.blade.php new file mode 100644 index 0000000..8b0ba24 --- /dev/null +++ b/resources/views/compartido/mensajes.blade.php @@ -0,0 +1,3 @@ +@if (session('mensaje-success')) +

{{ session('mensaje-success') }}

+@endif \ No newline at end of file diff --git a/resources/views/layouts/admin.blade.php b/resources/views/layouts/admin.blade.php new file mode 100644 index 0000000..51f7c26 --- /dev/null +++ b/resources/views/layouts/admin.blade.php @@ -0,0 +1,126 @@ + + + + + + + + + + @yield('title','Sistema Taller') + + + + + + + + + + + @stack('styles') + + + + + + + + + + +
+ + @yield('contenido') +
+ + + + + + + + + + + + + + + + + + + + + @stack('scripts') + +