<?php

use App\Http\Controllers\ExportController;
use App\Http\Controllers\ProductController;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Session;

/*
|--------------------------------------------------------------------------
| 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::middleware('mgrauth')->group(function (){
    Route::get('/', [ProductController::class, 'index'])->name('index');
    Route::get('/product/{id}', [ProductController::class, 'product'])->name('view_product');
    Route::post('/upload_xls', [ProductController::class, 'upload_xls'])->name('upload_xls');
    Route::post('/upload_image', [ProductController::class, 'upload_image'])->name('upload_image');
    Route::post('/save_product', [ProductController::class, 'save_product'])->name('save_product');
    Route::post('/update_image/{id}', [ProductController::class, 'update_image'])->name('update_image');
    Route::post('/select_export', [ProductController::class, 'select_export'])->name('select_export');
    Route::post('/export_docx', [ExportController::class, 'export_docx'])->name('export_docx');
    Route::get('/wait_export/{filename}', [ExportController::class, 'wait_export'])->name('wait_export');
    Route::get('/import_result/{filename}', [ProductController::class, 'import_result'])->name('import_result');
});

Route::get('logout', function (){
    Session::forget('user');
    return Redirect::to('http://manager.stroyprofit.com/logout');
})->name('logout');

