Initial commit: Lash Vanshy - Complete project with admin panel, gallery, products, and contact
This commit is contained in:
36
app/Http/Controllers/Frontend/GaleriaController.php
Executable file
36
app/Http/Controllers/Frontend/GaleriaController.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?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'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user