37 lines
921 B
PHP
Executable File
37 lines
921 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers\Frontend;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Galeria;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class GaleriaController extends Controller
|
|
{
|
|
/**
|
|
* Mostrar galería pública
|
|
*/
|
|
public function index(Request $request): View
|
|
{
|
|
$tipo = $request->get('tipo', 'todos');
|
|
|
|
$query = Galeria::activo()->ordenado();
|
|
|
|
if ($tipo !== 'todos') {
|
|
$query->where('tipo', $tipo);
|
|
}
|
|
|
|
$galeria = $query->paginate(12);
|
|
|
|
// Obtener estadísticas para los filtros
|
|
$stats = [
|
|
'total' => Galeria::activo()->count(),
|
|
'imagenes' => Galeria::activo()->where('tipo', 'imagen')->count(),
|
|
'videos' => Galeria::activo()->where('tipo', 'video')->count(),
|
|
];
|
|
|
|
return view('frontend.galeria.index', compact('galeria', 'stats', 'tipo'));
|
|
}
|
|
}
|