Skip to content

Commit

Permalink
Merge pull request #64 from Crudzaso/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
DiegoAndresRamirez authored Nov 12, 2024
2 parents 7c6a128 + 88aac10 commit 377c56e
Show file tree
Hide file tree
Showing 33 changed files with 594 additions and 584 deletions.
6 changes: 3 additions & 3 deletions Modules/Draws/app/Http/Controllers/DrawsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\Draws\Models\Draws;
use Modules\Lotery\Models\Lotery;
use Modules\Lottery\Models\Lottery;

class DrawsController extends Controller
{
Expand All @@ -17,7 +17,7 @@ public function index()

public function create()
{
$lotteries = Lotery::all();
$lotteries = Lottery::all();
return view('draws::create', compact('lotteries'));
}

Expand All @@ -37,7 +37,7 @@ public function store(Request $request)
public function edit($id)
{
$draw = Draws::findOrFail($id);
$lotteries = Lotery::all();
$lotteries = Lottery::all();
return view('draws::edit', compact('draw', 'lotteries'));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
@yield('content')

{{-- Vite JS --}}
@vite('Modules/Lotery/resources/assets/js/app.js', 'build-multimedia')
@vite('Modules/Lottery/resources/assets/js/app.js', 'build-multimedia')
</body>
2 changes: 1 addition & 1 deletion Modules/Payment/resources/views/layouts/master.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
@yield('content')

{{-- Vite JS --}}
@vite('Modules/Lotery/resources/assets/js/app.js', 'build-payment')
@vite('Modules/Lottery/resources/assets/js/app.js', 'build-payment')
</body>
39 changes: 35 additions & 4 deletions Modules/Raffle/app/Http/Controllers/RaffleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ public function destroy($id)
public function getRaffles(Request $request)
{
$query = Raffle::with('organizer', 'lottery');

if ($request->has('min_price')) {
$query->where('ticket_price', '>=', $request->input('min_price'));
}
if ($request->has('max_price')) {
$query->where('ticket_price', '<=', $request->input('max_price'));
}

if ($request->has('end_date')) {
$query->where('end_date', '<=', $request->input('end_date'));
}

$raffles = $query->paginate(6);
return response()->json($raffles);
}
Expand All @@ -104,7 +104,7 @@ public function getLastChanceRaffles()
->orderBy('end_date', 'asc')
->limit(5)
->get();

return response()->json($raffles);
}

Expand All @@ -114,5 +114,36 @@ public function getActiveRaffles()
$activeRaffles = Raffle::where('end_date', '>', now())->get();
return response()->json(['active_raffles' => $activeRaffles]);
}

public function getFilteredRaffles(Request $request)
{
$filter = $request->input('filter');
$date = $request->input('date');
$query = Raffle::with('organizer', 'lottery');

// Aplicar filtro adicional por fecha
if ($date) {
$query->whereDate('end_date', '>', $date);
}

switch ($filter) {
case 'popular':
$query->where('tickets_sold', '>=', 50)
->where('end_date', '>', now()->addDays(10));
break;
case 'last_chance':
$query->where('end_date', '<', now()->addDays(3));
break;
case 'flash':
$query->where('total_tickets', '<=', 50);
break;
default:
$query->where('end_date', '>', now());
break;
}

$raffles = $query->paginate(6);
return response()->json($raffles);
}

}
2 changes: 1 addition & 1 deletion Modules/Raffle/resources/views/layouts/master.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
@yield('content')

{{-- Vite JS --}}
@vite('Modules/Lotery/resources/assets/js/app.js', 'build-raffle')
@vite('Modules/Lottery/resources/assets/js/app.js', 'build-raffle')
</body>
2 changes: 1 addition & 1 deletion Modules/Reward/resources/views/layouts/master.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
@yield('content')

{{-- Vite JS --}}
@vite('Modules/Lotery/resources/assets/js/app.js', 'build-reward')
@vite('Modules/Lottery/resources/assets/js/app.js', 'build-reward')
</body>
2 changes: 1 addition & 1 deletion Modules/Ticket/resources/views/layouts/master.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
@yield('content')

{{-- Vite JS --}}
@vite('Modules/Lotery/resources/assets/js/app.js', 'build-ticket')
@vite('Modules/Lottery/resources/assets/js/app.js', 'build-ticket')
</body>
4 changes: 2 additions & 2 deletions app/Filament/Resources/DrawsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Filament\Forms\Components\TextArea;
use Filament\Forms\Components\Select;
use Filament\Tables\Columns\TextColumn;
use Modules\Lotery\Models\Lotery;
use Modules\Lottery\Models\Lottery;

class DrawsResource extends Resource
{
Expand All @@ -35,7 +35,7 @@ public static function form(Form $form): Form
Select::make('lottery_id')
->label('Lottery')
->options(function () {
return Lotery::all()->pluck('name', 'id');
return Lottery::all()->pluck('name', 'id');
})
->required()
->placeholder('Select Lottery'),
Expand Down
5 changes: 2 additions & 3 deletions app/Filament/Resources/RafflesResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
use Filament\Forms\Components\DateTimePicker;
use Modules\Raffle\Models\Raffle;
use App\Models\User; // Asegúrate de importar el modelo User
use Modules\Lotery\Models\Lotery;
use Modules\Lottery\Models\Lottery; // Asegúrate de importar el modelo Lottery
use Modules\Lottery\Models\Lottery;

class RafflesResource extends Resource
{
Expand Down Expand Up @@ -43,7 +42,7 @@ public static function form(Form $form): Form

Select::make('lottery_id')
->label('Lotería')
->options(Lotery::all()->pluck('name', 'id'))
->options(Lottery::all()->pluck('name', 'id'))
->required(),

TextInput::make('ticket_price')
Expand Down
10 changes: 10 additions & 0 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Inertia\Inertia;
use Modules\Raffle\Models\Raffle;

class UserController extends Controller
{
Expand Down Expand Up @@ -144,4 +145,13 @@ public function updateProfilePhoto(Request $request, User $user)
'profile_photo_url' => $user->profile_photo_url,
]);
}

public function activeRaffles()
{
$activeRaffles = Raffle::where('end_date', '>', now())->get();

return Inertia::render('ActiveRaffles', [
'raffles' => $activeRaffles,
]);
}
}
1 change: 0 additions & 1 deletion bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
'role' => \Spatie\Permission\Middleware\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middleware\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middleware\RoleOrPermissionMiddleware::class,
'admin.password.verify' => \App\Http\Middleware\AdminPasswordVerification::class,
]);
})
->withExceptions(function (Exceptions $exceptions) {
Expand Down
42 changes: 42 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"vue": "^3.3.13"
},
"dependencies": {
"@headlessui/vue": "^1.7.23",
"@splidejs/vue-splide": "^0.6.12",
"chart.js": "^4.4.6",
"lucide-vue-next": "^0.454.0",
Expand Down
Binary file added public/assets/media/auth/business-research.webp
Binary file not shown.
Binary file added public/assets/media/auth/cash-salary.webp
Binary file not shown.
Binary file added public/assets/media/auth/credit-card.webp
Binary file not shown.
Binary file added public/assets/media/auth/custom-filter.webp
Binary file not shown.
Binary file added public/assets/media/auth/family-money.webp
Binary file not shown.
Binary file added public/assets/media/auth/save-money-pig.webp
Binary file not shown.
89 changes: 89 additions & 0 deletions resources/js/Components/ActiveRaffleCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!-- RaffleCard.vue -->
<template>
<div class="raffle-card bg-white rounded-lg shadow-lg overflow-hidden transform hover:scale-105 transition-transform duration-300">
<!-- Imagen de la rifa -->
<div class="relative h-48 overflow-hidden">
<img
:src="raffle.multimedia?.[0]?.url || '/default-raffle.jpg'"
class="w-full h-full object-cover"
alt="Raffle Image"
/>
<div class="absolute top-0 right-0 bg-primary-600 text-white px-3 py-1 rounded-bl-lg">
{{ formatPrice(raffle.ticket_price) }}
</div>
</div>

<!-- Contenido de la tarjeta -->
<div class="p-4">
<h3 class="text-xl font-bold text-gray-800 mb-2 truncate">{{ raffle.name }}</h3>

<!-- Barra de progreso -->
<div class="mb-4">
<div class="flex justify-between text-sm mb-1">
<span>{{ raffle.tickets_sold }} vendidos</span>
<span>{{ raffle.total_tickets }} total</span>
</div>
<div class="w-full bg-gray-200 rounded-full h-2">
<div
class="bg-primary-600 rounded-full h-2 transition-all duration-300"
:style="{ width: `${(raffle.tickets_sold / raffle.total_tickets) * 100}%` }"
></div>
</div>
</div>

<!-- Detalles adicionales -->
<div class="flex justify-between items-center text-sm text-gray-600 mb-4">
<div class="flex items-center">
<i class="fas fa-user mr-1"></i>
<span>{{ raffle.organizer.name }}</span>
</div>
<div class="flex items-center">
<i class="fas fa-clock mr-1"></i>
<span>{{ formatTimeRemaining(raffle.end_date) }}</span>
</div>
</div>

<!-- Botón de acción -->
<button
class="w-full bg-primary-600 text-white py-2 rounded-lg hover:bg-primary-700 transition-colors duration-300"
@click="$emit('participate', raffle.id)"
>
Participar
</button>
</div>
</div>
</template>

<script>
export default {
name: 'RaffleCard',
props: {
raffle: {
type: Object,
required: true
}
},
methods: {
formatPrice(price) {
return new Intl.NumberFormat('es-MX', {
style: 'currency',
currency: 'MXN'
}).format(price)
},
formatTimeRemaining(endDate) {
const end = new Date(endDate)
const now = new Date()
const diff = end - now

const days = Math.floor(diff / (1000 * 60 * 60 * 24))

if (days > 0) {
return `${days} días restantes`
}

const hours = Math.floor(diff / (1000 * 60 * 60))
return `${hours} horas restantes`
}
}
}
</script>
2 changes: 1 addition & 1 deletion resources/js/Components/Dashboard/ActiveRaffles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const theme = computed(() => ({
}));
const redirectToRaffles = () => {
window.location.href = '/rifas-activas';
window.location.href = '/raffles/active';
};
const fetchRaffles = async () => {
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Components/Dashboard/HeroBanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { useDarkMode } from '@/composables/useDarkMode';
const { isDarkMode } = useDarkMode();
const handleExploreRaffles = () => {
window.location.href = '/rifas-activas';
window.location.href = '/raffles/active';
};
const handleBecomeOrganizer = () => {
Expand Down
Loading

0 comments on commit 377c56e

Please sign in to comment.