From 923e1ad19f158fc9050c48687c81244ba336d14e Mon Sep 17 00:00:00 2001 From: Damian Date: Fri, 28 Feb 2025 13:00:31 -0600 Subject: [PATCH 1/2] re direccion --- resources/views/auth/register.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index cfefd0f..f6fd536 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -96,7 +96,7 @@
From 2bd0c159fc452f6d41699eecfe3eb51748f310f3 Mon Sep 17 00:00:00 2001 From: Damian Date: Fri, 28 Feb 2025 14:04:14 -0600 Subject: [PATCH 2/2] Marcas crear editar --- app/Http/Controllers/MarcaController.php | 73 +++++++++++++++++++ app/Models/Marca.php | 15 ++++ database/factories/MarcaFactory.php | 23 ++++++ .../2025_02_28_192615_create_marcas_table.php | 28 +++++++ database/seeders/MarcaSeeder.php | 17 +++++ resources/views/layouts/dashboard.blade.php | 2 +- resources/views/marcas.blade.php | 46 ++++++++++++ resources/views/marcasCrearEditar.blade.php | 31 ++++++++ routes/web.php | 5 +- 9 files changed, 238 insertions(+), 2 deletions(-) create mode 100644 app/Http/Controllers/MarcaController.php create mode 100644 app/Models/Marca.php create mode 100644 database/factories/MarcaFactory.php create mode 100644 database/migrations/2025_02_28_192615_create_marcas_table.php create mode 100644 database/seeders/MarcaSeeder.php create mode 100644 resources/views/marcas.blade.php create mode 100644 resources/views/marcasCrearEditar.blade.php diff --git a/app/Http/Controllers/MarcaController.php b/app/Http/Controllers/MarcaController.php new file mode 100644 index 0000000..54c2174 --- /dev/null +++ b/app/Http/Controllers/MarcaController.php @@ -0,0 +1,73 @@ + $marcas]); + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + $marcas = Marca::all(); + return view('marcasCrearEditar',['marcas'=>$marcas]); + } + + /** + * Store a newly created resource in storage. + */ + public function store(Request $request) + { + $marca = new Marca($request->all()); + $marca->save(); + return redirect()->route('marca.index'); + } + + /** + * Display the specified resource. + */ + public function show(Marca $marca) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit($id) + { + $marca = Marca::find($id); + return view('marcasCrearEditar',['marca'=>$marca]); + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, $id) + { + $marca = Marca::find($id); + $marca->fill($request->all()); + $marca->save(); + return redirect()->route('marca.index'); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(Marca $marca) + { + // + } +} diff --git a/app/Models/Marca.php b/app/Models/Marca.php new file mode 100644 index 0000000..91be636 --- /dev/null +++ b/app/Models/Marca.php @@ -0,0 +1,15 @@ + + */ +class MarcaFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/migrations/2025_02_28_192615_create_marcas_table.php b/database/migrations/2025_02_28_192615_create_marcas_table.php new file mode 100644 index 0000000..cb30b5f --- /dev/null +++ b/database/migrations/2025_02_28_192615_create_marcas_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('nombre'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('marcas'); + } +}; diff --git a/database/seeders/MarcaSeeder.php b/database/seeders/MarcaSeeder.php new file mode 100644 index 0000000..bd53b8c --- /dev/null +++ b/database/seeders/MarcaSeeder.php @@ -0,0 +1,17 @@ +
  • - + Marcas diff --git a/resources/views/marcas.blade.php b/resources/views/marcas.blade.php new file mode 100644 index 0000000..3c05520 --- /dev/null +++ b/resources/views/marcas.blade.php @@ -0,0 +1,46 @@ +@extends('layouts.dashboard') + +@section('content') +
    + +
    +
    +

    Lista de Marcas

    +
    +
    +
    + + + + + + + + + + @foreach($marcas as $marca) + + + + + + @endforeach + +
    IDNombreAcciones
    {{ $marca->id }}{{ $marca->nombre }} + Editar +
    + @csrf + @method('DELETE') + +
    +
    +
    +
    +
    + +
    + +
  • +@endsection diff --git a/resources/views/marcasCrearEditar.blade.php b/resources/views/marcasCrearEditar.blade.php new file mode 100644 index 0000000..cad3dbf --- /dev/null +++ b/resources/views/marcasCrearEditar.blade.php @@ -0,0 +1,31 @@ +@extends('layouts.dashboard') + +@section('content') +
    +
    + @if($marca) +

    Editar Marca

    + @else +

    Crear Marca

    + @endif +
    +
    + @if($marca) +
    + @csrf + @method('PUT') + @else + + @csrf + @endif + +
    + + +
    + + Cancelar +
    +
    +
    +@endsection diff --git a/routes/web.php b/routes/web.php index 30c7c62..6a66fbe 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,7 +3,7 @@ use Illuminate\Support\Facades\Route; use App\Http\Controllers\usuariosController; use App\Http\Controllers\HomeController; - +use App\Http\Controllers\MarcaController; /* |-------------------------------------------------------------------------- | Web Routes @@ -21,6 +21,9 @@ Route::get('/', function () { Auth::routes(['register'=>true,'reset'=>true]); +Route::resource('marca', MarcaController::class); + + // Rutas protegidas que requieren autenticación Route::middleware(['auth'])->group(function () { Route::get('/dashboard', [HomeController::class, 'index'])->name('dashboard');