<?php

/*
|--------------------------------------------------------------------------
| 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!
|
 */

use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;

Route::get('lang', function () {
    $lang = session('lang', 'pt-br');
    if ($lang == 'pt-br') {
        $lang = "en";
    } else {
        $lang = "pt-br";
    }
    session(['lang' => $lang]);
    return redirect()->back();

})->name('lang');

Route::get('/', function () {
    $lang = session('lang', 'pt-br');
    App::setLocale($lang);

    return view('welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

Route::prefix('admin')->namespace('Admin')->group(function () {
    Route::resource('/users', 'UserController');
    Route::resource('/permissions', 'PermissionController');
    Route::resource('/roles', 'RoleController');
    Route::resource('/agendamentos', 'AgendamentoController');
});
//->middleware('auth')
