<?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');
    Route::get('/pesquisaTitulo', 'UserController@pesquisaTitulo')->name('pesquisaTitulo');
});
//->middleware('auth')

//Rotas de Agendamento
Route::any('/agendamentoTituloSede', function () {
    $routeName = 'agendamentos';
    $page = trans('agendamento.agendamento_list');
    $page_create = trans('agendamento.agendamento');

    $breadcrumb = [
        (object) ['url' => route('home'), 'title' => trans('agendamento.home')],
        (object) ['url' => route($routeName . '.index'), 'title' => trans('agendamento.list', ['page' => $page])],
        (object) ['url' => '', 'title' => trans('agendamento.create_crud', ['page' => $page_create])],
    ];
    return view('admin.' . $routeName . '.agendamentoTituloSede', ['page' => $page, 'page_create' => $page_create, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);
})->name('agendamentoTituloSede');

Route::any('/agendamentoTituloHora', function () {
    $routeName = 'agendamentos';
    $page = trans('agendamento.agendamento_list');
    $page_create = trans('agendamento.agendamento');

    $breadcrumb = [
        (object) ['url' => route('home'), 'title' => trans('agendamento.home')],
        (object) ['url' => route($routeName . '.index'), 'title' => trans('agendamento.list', ['page' => $page])],
        (object) ['url' => '', 'title' => trans('agendamento.create_crud', ['page' => $page_create])],
    ];
    return view('admin.' . $routeName . '.agendamentoTituloHora', ['page' => $page, 'page_create' => $page_create, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);
})->name('agendamentoTituloHora');

Route::any('/agendamentoConfere', function () {
    $routeName = 'agendamentos';
    $page = trans('agendamento.agendamento_list');
    $page_create = trans('agendamento.agendamento');

    $breadcrumb = [
        (object) ['url' => route('home'), 'title' => trans('agendamento.home')],
        (object) ['url' => route($routeName . '.index'), 'title' => trans('agendamento.list', ['page' => $page])],
        (object) ['url' => '', 'title' => trans('agendamento.create_crud', ['page' => $page_create])],
    ];
    return view('admin.' . $routeName . '.agendamentoConfere', ['page' => $page, 'page_create' => $page_create, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);
})->name('agendamentoConfere');

Route::any('/agendamentoConfere2', function () {
    $routeName = 'agendamentos';
    $page = trans('agendamento.agendamento_list');
    $page_create = trans('agendamento.agendamento');

    $breadcrumb = [
        (object) ['url' => route('home'), 'title' => trans('agendamento.home')],
        (object) ['url' => route($routeName . '.index'), 'title' => trans('agendamento.list', ['page' => $page])],
        (object) ['url' => '', 'title' => trans('agendamento.create_crud', ['page' => $page_create])],
    ];
    return view('admin.' . $routeName . '.agendamentoConfere2', ['page' => $page, 'page_create' => $page_create, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);
})->name('agendamentoConfere2');

Route::any('/agendamentoConfirmacao', function () {
    $routeName = 'agendamentos';
    $page = trans('agendamento.agendamento_list');
    $page_create = trans('agendamento.agendamento');

    $breadcrumb = [
        (object) ['url' => route('home'), 'title' => trans('agendamento.home')],
        (object) ['url' => route($routeName . '.index'), 'title' => trans('agendamento.list', ['page' => $page])],
        (object) ['url' => '', 'title' => trans('agendamento.create_crud', ['page' => $page_create])],
    ];
    return view('admin.' . $routeName . '.agendamentoConfirmacao', ['page' => $page, 'page_create' => $page_create, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);
})->name('agendamentoConfirmacao');

Route::any('/agendamentoTitulo', function () {
    $routeName = 'agendamentos';
    $page = trans('agendamento.agendamento_list');
    $page_create = trans('agendamento.agendamento');

    $breadcrumb = [
        (object) ['url' => route('home'), 'title' => trans('agendamento.home')],
        (object) ['url' => route($routeName . '.index'), 'title' => trans('agendamento.list', ['page' => $page])],
        (object) ['url' => '', 'title' => trans('agendamento.create_crud', ['page' => $page_create])],
    ];

    return view('admin.' . $routeName . '.agendamentoTitulo', ['page' => $page, 'page_create' => $page_create, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);

})->name('agendamentoTitulo');


Route::any('/agendamentoTituloEntrega', function () {
    $routeName = 'agendamentos';
    $page = trans('agendamento.agendamento_list');
    $page_create = trans('agendamento.agendamento');

    $breadcrumb = [
        (object) ['url' => route('home'), 'title' => trans('agendamento.home')],
        (object) ['url' => route($routeName . '.index'), 'title' => trans('agendamento.list', ['page' => $page])],
        (object) ['url' => '', 'title' => trans('agendamento.create_crud', ['page' => $page_create])],
    ];

    return view('admin.' . $routeName . '.agendamentoTituloEntrega', ['page' => $page, 'page_create' => $page_create, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);

})->name('agendamentoTituloEntrega');


Route::any('/agendamentoTituloSede', function () {
    $routeName = 'agendamentos';
    $page = trans('agendamento.agendamento_list');
    $page_create = trans('agendamento.agendamento');

    $breadcrumb = [
        (object) ['url' => route('home'), 'title' => trans('agendamento.home')],
        (object) ['url' => route($routeName . '.index'), 'title' => trans('agendamento.list', ['page' => $page])],
        (object) ['url' => '', 'title' => trans('agendamento.create_crud', ['page' => $page_create])],
    ];

    return view('admin.' . $routeName . '.agendamentoTituloSede', ['page' => $page, 'page_create' => $page_create, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);

})->name('agendamentoTituloSede');

Route::any('/agendamentoContato', function () {
    $routeName = 'agendamentos';
    $page = trans('agendamento.agendamento_list');
    $page_create = trans('agendamento.agendamento');

    $breadcrumb = [
        (object) ['url' => route('home'), 'title' => trans('agendamento.home')],
        (object) ['url' => route($routeName . '.index'), 'title' => trans('agendamento.list', ['page' => $page])],
        (object) ['url' => '', 'title' => trans('agendamento.create_crud', ['page' => $page_create])],
    ];

    return view('admin.' . $routeName . '.agendamentoContato', ['page' => $page, 'page_create' => $page_create, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);
    
})->name('agendamentoContato');

Route::any('/cadastroConfirmacao', function () {
    $routeName = 'users';
    $page = trans('agendamento.agendamento_list');
    $page_create = trans('agendamento.agendamento');

    $breadcrumb = [
        (object) ['url' => route('home'), 'title' => trans('agendamento.home')],
        (object) ['url' => route($routeName . '.index'), 'title' => trans('agendamento.list', ['page' => $page])],
        (object) ['url' => '', 'title' => trans('agendamento.create_crud', ['page' => $page_create])],
    ];

    return view('admin.' . $routeName . '.cadastroConfirmacao', ['page' => $page, 'page_create' => $page_create, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);
    
})->name('cadastroConfirmacao');






//->middleware('auth')
