<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

/*
Route::get('/', function () {
    //return view('welcome');
    return view('front.home');
});
*/

Route::get('install-storage', function () {

    \Artisan::call('clear-compiled');

    \Artisan::call('cache:clear');

    \Artisan::call('config:clear');

    \Artisan::call('optimize:clear');

    \Artisan::call('route:clear');

    \Artisan::call('view:clear');

    \Artisan::call('storage:link');

    $storage_path = storage_path('app/public');

    $public_path = realpath(base_path().'/public_html') . 'storage';



   symlink($storage_path, $public_path);



});

Route::get('clear-cache', function () {

    \Artisan::call('clear-compiled');

    \Artisan::call('cache:clear');

    \Artisan::call('config:clear');

    \Artisan::call('optimize:clear');

    \Artisan::call('route:clear');

    \Artisan::call('view:clear');

});

/*
Route::get('migrate', function () {

    \Artisan::call('migrate');
    \Artisan::call('db:seed');

});

*/

// Route::get('rollback', function () {

//     \Artisan::call('migrate:rollback');

// });


Route::get('/', [App\Http\Controllers\HomeController::class, 'home'])->name('home');
Route::get('/empresa', [App\Http\Controllers\HomeController::class, 'empresa'])->name('empresa');
// Route::get('/clientes', [App\Http\Controllers\HomeController::class, 'clientes'])->name('clientes');

Route::get('/productos', [App\Http\Controllers\HomeController::class, 'productos'])->name('categorias'); // Todas las categorias
Route::get('/producto/{id}', [App\Http\Controllers\ProductoController::class, 'show'])->name('producto'); // Página del producto con id = {id}
Route::get('/productos/{id}', [App\Http\Controllers\CategoriaController::class, 'show'])->name('categoria'); // Productos de la categoria con id = {id}

Route::get('/producto/ficha/{id}', [App\Http\Controllers\ProductoController::class, 'descargarFicha'])->name('descargarFicha');

Route::get('/calidad', [App\Http\Controllers\HomeController::class, 'calidad'])->name('calidad');
Route::get('/calidad/archivo', [App\Http\Controllers\HomeController::class, 'descargarArchivo'])->name('descargarArchivo');
Route::get('/novedades', [App\Http\Controllers\HomeController::class, 'novedades'])->name('novedades');
Route::get('/novedad/{id}', [App\Http\Controllers\NovedadController::class, 'show'])->name('showNovedad');

Route::get('/catalogo', [App\Http\Controllers\HomeController::class, 'descargarCatalogo'])->name('descargarCatalogo');

Route::get('/presupuesto/{id?}', [App\Http\Controllers\HomeController::class, 'presupuesto'])->name('presupuesto');
Route::get('/contacto', [App\Http\Controllers\HomeController::class, 'contacto'])->name('contacto');

Route::get('/distribuidores', [App\Http\Controllers\DistribuidoresController::class, 'show'])->name('distribuidores');
Route::get('/distribuidores/buscar', [App\Http\Controllers\DistribuidoresController::class, 'buscar'])->name('buscarDistribuidores');

Route::post('/solicitarPresupuesto', [App\Http\Controllers\HomeController::class, 'envioSolicitudPresupuesto'])->name('formPresupuesto');
Route::post('/contacto', [App\Http\Controllers\HomeController::class, 'mensajeContacto'])->name('formContacto');

Auth::routes();

Route::group(['prefix' => 'adm', 'middleware' => ['auth']], function(){
    Route::post('/categoria/create/{seccion}', [App\Http\Controllers\CategoriaController::class, 'store'])->name('createCategoria');
    Route::post('/categoria/edit/{seccion}', [App\Http\Controllers\CategoriaController::class, 'update'])->name('editCategoria');

    Route::get('categorias/{seccion}', [App\Http\Controllers\CategoriaController::class, 'index'])->name('indexCategorias');
    Route::get('/categoria/{seccion}/crear', [App\Http\Controllers\CategoriaController::class, 'create'])->name('crearCategoria');
    Route::get('/categoria/{id}/{seccion}', [App\Http\Controllers\CategoriaController::class, 'edit'])->name('editarCategoria');
    Route::get('/categoria/{id}/eliminar/{seccion}', [App\Http\Controllers\CategoriaController::class, 'destroy'])->name('eliminarCategoria');

    Route::get('/novedades/', [App\Http\Controllers\NovedadController::class, 'index'])->name('indexNovedades');
    Route::get('/novedad/crear', [App\Http\Controllers\NovedadController::class, 'create'])->name('crearNovedad');
    Route::get('/novedad/{id}/editar', [App\Http\Controllers\NovedadController::class, 'edit'])->name('editarNovedad');
    Route::get('/novedad/{id}/eliminar', [App\Http\Controllers\NovedadController::class, 'destroy'])->name('eliminarNovedad');
    
    Route::post('/catalogo/edit', [App\Http\Controllers\EmpresaController::class, 'subirCatalogo'])->name('subirCatalogo');
    
    
    Route::post('/novedad/create', [App\Http\Controllers\NovedadController::class, 'store'])->name('createNovedad');
    Route::post('/novedad/edit', [App\Http\Controllers\NovedadController::class, 'update'])->name('editNovedad');

    Route::get('/usuarios', [App\Http\Controllers\UsuarioController::class, 'index'])->name('indexUsuarios');
    Route::get('/usuario/{id}', [App\Http\Controllers\UsuarioController::class, 'edit'])->name('editarUsuario');

    Route::post('/usuario/edit', [App\Http\Controllers\UsuarioController::class, 'update'])->name('editUsuario');

    Route::get('/inicio/editar', [App\Http\Controllers\InicioController::class, 'edit'])->name('editarInicio');
    Route::post('/inicio/edit', [App\Http\Controllers\InicioController::class, 'update'])->name('editInicio');

    Route::get('/slider/{seccion}', [App\Http\Controllers\SliderController::class, 'index'])->name('slider');
    Route::get('/slider/{seccion}/crear', [App\Http\Controllers\SliderController::class, 'create'])->name('nuevoslider');
    Route::get('/slider/{seccion}/{id}/editar', [App\Http\Controllers\SliderController::class, 'edit'])->name('editarslider');
    Route::get('/slider/eliminar/{id}', [App\Http\Controllers\SliderController::class, 'destroy'])->name('eliminarslider');

    Route::post('/slider/create/{seccion}', [App\Http\Controllers\SliderController::class, 'store'])->name('createslider');
    Route::put('/slider/edit/{seccion}/{id}', [App\Http\Controllers\SliderController::class, 'update'])->name('updateslider');

    Route::get('/productos', [App\Http\Controllers\ProductoController::class, 'index'])->name('indexProductos');
    Route::get('/producto/crear', [App\Http\Controllers\ProductoController::class, 'create'])->name('crearProducto');
    Route::get('/producto/{id}', [App\Http\Controllers\ProductoController::class, 'edit'])->name('editarProducto');
    Route::get('/producto/{id}/eliminar', [App\Http\Controllers\ProductoController::class, 'destroy'])->name('eliminarProducto');

    Route::get('/producto/{id}/eliminarFoto5', [App\Http\Controllers\ProductoController::class, 'eliminarFoto5'])->name('eliminarFoto5');
    Route::get('/producto/{id}/eliminarFoto4', [App\Http\Controllers\ProductoController::class, 'eliminarFoto4'])->name('eliminarFoto4');
    Route::get('/producto/{id}/eliminarFoto3', [App\Http\Controllers\ProductoController::class, 'eliminarFoto3'])->name('eliminarFoto3');
    Route::get('/producto/{id}/eliminarFoto2', [App\Http\Controllers\ProductoController::class, 'eliminarFoto2'])->name('eliminarFoto2');

    Route::post('/producto/create', [App\Http\Controllers\ProductoController::class, 'store'])->name('createProducto');
    Route::post('/producto/edit', [App\Http\Controllers\ProductoController::class, 'update'])->name('editProducto');
    
    Route::get('/distribuidores', [App\Http\Controllers\DistribuidoresController::class, 'index'])->name('indexDistribuidores');
    Route::get('/distribuidor/crear', [App\Http\Controllers\DistribuidoresController::class, 'create'])->name('crearDistribuidor');
    Route::get('/distribuidor/{id}', [App\Http\Controllers\DistribuidoresController::class, 'edit'])->name('editarDistribuidor');
    Route::get('/distribuidor/{id}/eliminar', [App\Http\Controllers\DistribuidoresController::class, 'destroy'])->name('eliminarDistribuidor');
    
    Route::post('/distribuidor/create', [App\Http\Controllers\DistribuidoresController::class, 'store'])->name('createDistribuidor');
    Route::post('/distribuidor/edit', [App\Http\Controllers\DistribuidoresController::class, 'update'])->name('editDistribuidor');

    // Route::get('/clientes', [App\Http\Controllers\ClienteController::class, 'index'])->name('indexClientes');
    // Route::get('/cliente/agregar', [App\Http\Controllers\ClienteController::class, 'create'])->name('crearCliente');
    // Route::get('/cliente/{id}', [App\Http\Controllers\ClienteController::class, 'edit'])->name('editarCliente');
    // Route::get('/cliente/{id}/eliminar', [App\Http\Controllers\ClienteController::class, 'destroy'])->name('eliminarCliente');

    // Route::post('/cliente/edit', [App\Http\Controllers\ClienteController::class, 'update'])->name('editCliente');
    // Route::post('/cliente/create', [App\Http\Controllers\ClienteController::class, 'store'])->name('createCliente');

    Route::get('/contacto', [App\Http\Controllers\ContactoController::class, 'edit'])->name('viasdecontacto');
    Route::post('/contacto/edit', [App\Http\Controllers\ContactoController::class, 'update'])->name('editContacto');

    Route::get('/empresa/editar', [App\Http\Controllers\EmpresaController::class, 'edit'])->name('editarEmpresa');
    Route::post('/empresa/edit', [App\Http\Controllers\EmpresaController::class, 'update'])->name('editEmpresa');
    
    Route::get('/calidad/editar', [App\Http\Controllers\CalidadController::class, 'edit'])->name('editarCalidad');
    Route::post('/calidad/edit', [App\Http\Controllers\CalidadController::class, 'update'])->name('editCalidad');

    Route::get('/redes/editar', [App\Http\Controllers\RedesController::class, 'edit'])->name('editarRedes');
    Route::post('/redes/edit', [App\Http\Controllers\RedesController::class, 'update'])->name('editRedes');

    // Route::get('/', [App\Http\Controllers\CategoriaController::class, 'index'])->name('adm');
});
/*Route::middleware(['auth'])->group(function () {
});*/

// Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');

// Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
