-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create: create the raffle section in the administrator panel
- Loading branch information
1 parent
cb13066
commit be9a178
Showing
8 changed files
with
275 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,109 @@ | ||
@extends('raffle::layouts.master') | ||
<!-- resources/views/raffles/edit.blade.php --> | ||
|
||
@section('content') | ||
<div class="container mx-auto px-6 py-10"> | ||
<h1 class="text-3xl font-extrabold text-gray-800 mb-6">Editar Rifa</h1> | ||
<form action="{{ route('raffles.update', $raffle->id) }}" method="POST"> | ||
@csrf | ||
@method('PUT') | ||
@extends('adminlte::page') | ||
|
||
<div class="mb-4"> | ||
<label class="block text-sm font-medium text-gray-700">Organizador</label> | ||
<select name="organizer_id" class="w-full px-4 py-2 border rounded-lg" required> | ||
@foreach($organizers as $user) | ||
<option value="{{ $user->id }}" {{ $raffle->organizer_id == $user->id ? 'selected' : '' }}> | ||
{{ $user->name }} | ||
</option> | ||
@endforeach | ||
</select> | ||
</div> | ||
@section('title', 'Editar Rifa') | ||
|
||
<div class="mb-4"> | ||
<label class="block text-sm font-medium text-gray-700">Lotería</label> | ||
<select name="lottery_id" class="w-full px-4 py-2 border rounded-lg" required> | ||
@foreach($lotteries as $lottery) | ||
<option value="{{ $lottery->id }}" {{ $raffle->lottery_id == $lottery->id ? 'selected' : '' }}> | ||
{{ $lottery->name }} | ||
</option> | ||
@endforeach | ||
</select> | ||
</div> | ||
@section('content_header') | ||
<h1>Editar Rifa</h1> | ||
@stop | ||
|
||
<div class="mb-4"> | ||
<label class="block text-sm font-medium text-gray-700">Precio del Ticket</label> | ||
<input type="number" name="ticket_price" value="{{ $raffle->ticket_price }}" class="w-full px-4 py-2 border rounded-lg" required> | ||
@section('content') | ||
<div class="container-fluid"> | ||
<div class="card"> | ||
<div class="card-header bg-primary"> | ||
<h3 class="card-title text-white">Editar Rifa</h3> | ||
</div> | ||
<div class="card-body"> | ||
<form action="{{ route('raffles.update', $raffle->id) }}" method="POST"> | ||
@csrf | ||
@method('PUT') | ||
|
||
<div class="mb-4"> | ||
<label class="block text-sm font-medium text-gray-700">Total de Tickets</label> | ||
<input type="number" name="total_tickets" value="{{ $raffle->total_tickets }}" class="w-full px-4 py-2 border rounded-lg" required> | ||
</div> | ||
<!-- Organizador --> | ||
<div class="form-group"> | ||
<label>Organizador</label> | ||
<select name="organizer_id" class="form-control select2" style="width: 100%;" required> | ||
@foreach($organizers as $user) | ||
<option value="{{ $user->id }}" {{ $raffle->organizer_id == $user->id ? 'selected' : '' }}> | ||
{{ $user->name }} | ||
</option> | ||
@endforeach | ||
</select> | ||
</div> | ||
|
||
<div class="mb-4"> | ||
<label class="block text-sm font-medium text-gray-700">Tickets Vendidos</label> | ||
<input type="number" name="tickets_sold" value="{{ $raffle->tickets_sold }}" class="w-full px-4 py-2 border rounded-lg"> | ||
</div> | ||
<!-- Lotería --> | ||
<div class="form-group"> | ||
<label>Lotería</label> | ||
<select name="lottery_id" class="form-control select2" style="width: 100%;" required> | ||
@foreach($lotteries as $lottery) | ||
<option value="{{ $lottery->id }}" {{ $raffle->lottery_id == $lottery->id ? 'selected' : '' }}> | ||
{{ $lottery->name }} | ||
</option> | ||
@endforeach | ||
</select> | ||
</div> | ||
|
||
<div class="mb-4"> | ||
<label class="block text-sm font-medium text-gray-700">Descripción</label> | ||
<textarea name="description" class="w-full px-4 py-2 border rounded-lg">{{ $raffle->description }}</textarea> | ||
</div> | ||
<!-- Precio del Ticket --> | ||
<div class="form-group"> | ||
<label>Precio del Ticket</label> | ||
<input type="number" name="ticket_price" value="{{ $raffle->ticket_price }}" class="form-control" required> | ||
</div> | ||
|
||
<div class="mb-4"> | ||
<label class="block text-sm font-medium text-gray-700">Fecha de Inicio</label> | ||
<input type="datetime-local" name="start_date" value="{{ \Carbon\Carbon::parse($raffle->start_date)->format('Y-m-d\TH:i') }}" class="w-full px-4 py-2 border rounded-lg" required> | ||
</div> | ||
<!-- Total de Tickets --> | ||
<div class="form-group"> | ||
<label>Total de Tickets</label> | ||
<input type="number" name="total_tickets" value="{{ $raffle->total_tickets }}" class="form-control" required> | ||
</div> | ||
|
||
<div class="mb-4"> | ||
<label class="block text-sm font-medium text-gray-700">Fecha de Finalización</label> | ||
<input type="datetime-local" name="end_date" value="{{ \Carbon\Carbon::parse($raffle->end_date)->format('Y-m-d\TH:i') }}" class="w-full px-4 py-2 border rounded-lg" required> | ||
</div> | ||
<!-- Tickets Vendidos --> | ||
<div class="form-group"> | ||
<label>Tickets Vendidos</label> | ||
<input type="number" name="tickets_sold" value="{{ $raffle->tickets_sold }}" class="form-control"> | ||
</div> | ||
|
||
<!-- Descripción --> | ||
<div class="form-group"> | ||
<label>Descripción</label> | ||
<textarea name="description" class="form-control">{{ $raffle->description }}</textarea> | ||
</div> | ||
|
||
<!-- Fecha de Inicio --> | ||
<div class="form-group"> | ||
<label>Fecha de Inicio</label> | ||
<input type="datetime-local" name="start_date" value="{{ \Carbon\Carbon::parse($raffle->start_date)->format('Y-m-d\TH:i') }}" class="form-control" required> | ||
</div> | ||
|
||
<!-- Fecha de Finalización --> | ||
<div class="form-group"> | ||
<label>Fecha de Finalización</label> | ||
<input type="datetime-local" name="end_date" value="{{ \Carbon\Carbon::parse($raffle->end_date)->format('Y-m-d\TH:i') }}" class="form-control" required> | ||
</div> | ||
|
||
<button type="submit" class="px-6 py-2 bg-blue-600 text-white rounded-lg">Actualizar</button> | ||
</form> | ||
<!-- Botón Actualizar --> | ||
<div class="form-group"> | ||
<button type="submit" class="btn btn-primary"> | ||
<i class="fas fa-save"></i> Actualizar | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
@endsection | ||
@stop | ||
|
||
@section('css') | ||
<style> | ||
.select2-container .select2-selection--single { | ||
height: 38px !important; | ||
} | ||
</style> | ||
@stop | ||
|
||
@section('js') | ||
<script> | ||
// Inicializar Select2 para los dropdowns | ||
$(document).ready(function() { | ||
$('.select2').select2(); | ||
}); | ||
</script> | ||
@stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,169 @@ | ||
@extends('raffle::layouts.master') | ||
<!-- resources/views/raffles/index.blade.php --> | ||
|
||
@extends('adminlte::page') | ||
|
||
@section('title', 'Gestión de Rifas') | ||
|
||
@section('content_header') | ||
<h1>Gestión de Rifas</h1> | ||
@stop | ||
|
||
@section('content') | ||
<div class="container mx-auto px-6 py-10"> | ||
<h1 class="text-3xl font-extrabold text-gray-800 mb-6">Gestión de Rifas</h1> | ||
<a href="{{ route('raffles.create') }}" class="px-6 py-2 bg-green-600 text-white rounded-lg mb-4">Nueva Rifa</a> | ||
|
||
<div class="bg-white shadow-lg rounded-lg overflow-hidden"> | ||
<table class="min-w-full divide-y divide-gray-200"> | ||
<thead class="bg-blue-50"> | ||
<tr> | ||
<th class="px-6 py-3 text-left text-xs font-bold text-gray-600">Organizador</th> | ||
<th class="px-6 py-3 text-left text-xs font-bold text-gray-600">Lotería</th> | ||
<th class="px-6 py-3 text-left text-xs font-bold text-gray-600">Precio del Ticket</th> | ||
<th class="px-6 py-3 text-left text-xs font-bold text-gray-600">Acciones</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach($raffles as $raffle) | ||
<tr class="hover:bg-gray-100"> | ||
<td class="px-6 py-4">{{ $raffle->organizer->name }}</td> | ||
<td class="px-6 py-4">{{ $raffle->lottery->name }}</td> | ||
<td class="px-6 py-4">${{ number_format($raffle->ticket_price, 2) }}</td> | ||
<td class="px-6 py-4"> | ||
<a href="{{ route('raffles.edit', $raffle->id) }}" class="px-4 py-2 bg-yellow-500 text-white rounded-lg">Editar</a> | ||
<form action="{{ route('raffles.destroy', $raffle->id) }}" method="POST" class="inline"> | ||
@csrf | ||
@method('DELETE') | ||
<button type="submit" class="px-4 py-2 bg-red-600 text-white rounded-lg">Eliminar</button> | ||
</form> | ||
</td> | ||
<div class="container-fluid"> | ||
<!-- Botón para crear nueva rifa --> | ||
<div class="mb-4"> | ||
<a href="{{ route('raffles.create') }}" class="btn btn-success"> | ||
<i class="fas fa-plus mr-2"></i> Nueva Rifa | ||
</a> | ||
</div> | ||
|
||
<!-- Contenedor de la tabla --> | ||
<div class="card"> | ||
<div class="card-header bg-primary"> | ||
<h3 class="card-title text-white">Lista de Rifas</h3> | ||
</div> | ||
<div class="card-body p-0"> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th>Organizador</th> | ||
<th>Nombre</th> | ||
<th>Lotería</th> | ||
<th>Precio del Ticket</th> | ||
<th>Acciones</th> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
</thead> | ||
<tbody> | ||
@forelse($raffles as $raffle) | ||
<tr> | ||
<td>{{ $raffle->organizer->name }}</td> | ||
<td>{{ $raffle->name }}</td> | ||
<td>{{ $raffle->lottery->name }}</td> | ||
<td>${{ number_format($raffle->ticket_price, 2) }}</td> | ||
<td> | ||
<!-- Botón Editar --> | ||
<a href="{{ route('raffles.edit', $raffle->id) }}" class="btn btn-warning btn-sm"> | ||
<i class="fas fa-edit"></i> Editar | ||
</a> | ||
<!-- Botón Eliminar --> | ||
<form action="{{ route('raffles.destroy', $raffle->id) }}" method="POST" class="d-inline"> | ||
@csrf | ||
@method('DELETE') | ||
<button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('¿Estás seguro de eliminar esta rifa?')"> | ||
<i class="fas fa-trash-alt"></i> Eliminar | ||
</button> | ||
</form> | ||
</td> | ||
</tr> | ||
@empty | ||
<tr> | ||
<td colspan="4" class="text-center">No hay rifas registradas.</td> | ||
</tr> | ||
@endforelse | ||
</tbody> | ||
</table> | ||
</div> | ||
<div class="card-footer clearfix"> | ||
<!-- Paginación personalizada --> | ||
@if ($raffles->hasPages()) | ||
<nav class="pagination-custom"> | ||
<ul class="pagination d-flex justify-content-center"> | ||
{{-- Botón "Anterior" --}} | ||
@if ($raffles->onFirstPage()) | ||
<li class="page-item disabled"> | ||
<span class="page-link">« Anterior</span> | ||
</li> | ||
@else | ||
<li class="page-item"> | ||
<a href="{{ $raffles->previousPageUrl() }}" class="page-link">« Anterior</a> | ||
</li> | ||
@endif | ||
|
||
{{-- Números de página --}} | ||
@foreach ($raffles->getUrlRange(1, $raffles->lastPage()) as $page => $url) | ||
@if ($page == $raffles->currentPage()) | ||
<li class="page-item active"> | ||
<span class="page-link">{{ $page }}</span> | ||
</li> | ||
@else | ||
<li class="page-item"> | ||
<a href="{{ $url }}" class="page-link">{{ $page }}</a> | ||
</li> | ||
@endif | ||
@endforeach | ||
|
||
{{-- Botón "Siguiente" --}} | ||
@if ($raffles->hasMorePages()) | ||
<li class="page-item"> | ||
<a href="{{ $raffles->nextPageUrl() }}" class="page-link">Siguiente »</a> | ||
</li> | ||
@else | ||
<li class="page-item disabled"> | ||
<span class="page-link">Siguiente »</span> | ||
</li> | ||
@endif | ||
</ul> | ||
</nav> | ||
@endif | ||
</div> | ||
</div> | ||
|
||
<!-- Componente de Livewire para rifas activas --> | ||
<div class="mt-4"> | ||
<active-raffles></active-raffles> | ||
</div> | ||
</div> | ||
@endsection | ||
@stop | ||
|
||
@section('css') | ||
<style> | ||
/* Estilos adicionales */ | ||
.btn { | ||
font-size: 0.9rem; | ||
} | ||
/* Estilos para la paginación personalizada */ | ||
.pagination-custom .pagination { | ||
padding: 0; | ||
list-style: none; | ||
} | ||
.pagination-custom .page-item { | ||
display: inline-block; | ||
margin: 0 5px; | ||
} | ||
.pagination-custom .page-link { | ||
padding: 0.5rem 0.75rem; | ||
color: #007bff; | ||
text-decoration: none; | ||
border: 1px solid #ddd; | ||
border-radius: 0.25rem; | ||
} | ||
.pagination-custom .page-item.active .page-link { | ||
background-color: #007bff; | ||
color: #fff; | ||
border-color: #007bff; | ||
} | ||
.pagination-custom .page-item.disabled .page-link { | ||
color: #6c757d; | ||
pointer-events: none; | ||
background-color: #f8f9fa; | ||
} | ||
</style> | ||
@stop | ||
|
||
@section('js') | ||
<script> | ||
// Mensaje de confirmación para eliminar | ||
document.querySelectorAll('form').forEach(form => { | ||
form.addEventListener('submit', function (event) { | ||
if (!confirm('¿Estás seguro de eliminar esta rifa?')) { | ||
event.preventDefault(); | ||
} | ||
}); | ||
}); | ||
</script> | ||
@stop |
Oops, something went wrong.