diff --git a/Modules/Raffle/app/Http/Controllers/RaffleController.php b/Modules/Raffle/app/Http/Controllers/RaffleController.php index 2ecd8ed..1fc0218 100644 --- a/Modules/Raffle/app/Http/Controllers/RaffleController.php +++ b/Modules/Raffle/app/Http/Controllers/RaffleController.php @@ -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, @@ -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) { diff --git a/resources/js/Components/Dashboard/RaffleCard.vue b/resources/js/Components/Dashboard/RaffleCard.vue index 2107b1e..a3805c0 100644 --- a/resources/js/Components/Dashboard/RaffleCard.vue +++ b/resources/js/Components/Dashboard/RaffleCard.vue @@ -1,174 +1,206 @@ @@ -192,6 +224,7 @@ const referenceNumber = ref(''); const numbers = ref([]); const selectedNumber = ref([]); const showWarningModal = ref(false); +const defaultImage = '/assets/media/auth/Login-image.svg'; const countdown = ref({ days: 0, hours: 0, @@ -200,6 +233,10 @@ const countdown = ref({ }); const countdownEnded = ref(false); +const handleImageError = (event) => { + event.target.src = defaultImage; +}; + const calculateCountdown = () => { const now = new Date(); const endDate = new Date(raffleProps.raffle.end_date);