Skip to content

Commit

Permalink
fix: fix errors in the raffle images
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndresRamirez committed Dec 9, 2024
1 parent 193dfb9 commit b3fe9e9
Show file tree
Hide file tree
Showing 2 changed files with 203 additions and 154 deletions.
18 changes: 15 additions & 3 deletions Modules/Raffle/app/Http/Controllers/RaffleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,18 @@ public function store(Request $request)
'description' => 'nullable|string',
'start_date' => 'required|date',
'end_date' => 'required|date|after:start_date',
'image' => 'nullable|image|max:2048', // Validar si es una imagen
]);


$imagePath = null;

// Verificar si se subió una imagen
if ($request->hasFile('image')) {
// Guardar la imagen en el disco 'public' y obtener la ruta
$imagePath = $request->file('image')->store('raffle_images', 'public');
}

// Crear la rifa
Raffle::create([
'name' => $request->name,
'organizer_id' => $request->organizer_id,
Expand All @@ -51,11 +61,13 @@ public function store(Request $request)
'description' => $request->description,
'start_date' => $request->start_date,
'end_date' => $request->end_date,
'total_sales' => 0, // valor predeterminado de total_sales
'total_sales' => 0, // Valor predeterminado
'image' => $imagePath, // Guardar la ruta de la imagen en la base de datos
]);

return redirect()->route('raffles.index')->with('success', 'Rifa creada exitosamente.');
}


public function edit($id)
{
Expand Down
Loading

0 comments on commit b3fe9e9

Please sign in to comment.