<?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::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('/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('/pesquisaTitulo', 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 . '.pesquisaTitulo', ['page' => $page, 'page_create' => $page_create, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);
    
})->name('pesquisaTitulo');

Route::any('/resultadoPesquisa', function () {
    $columnList = ['id' => '#', 'municipio' => trans('agendamento.municipio'), 'detentor' => trans('agendamento.name'),
            'cpf' => trans('agendamento.cpf'), 'titulo' => trans('agendamento.titulo'), 'nome_mae' => trans('agendamento.nome_mae'),
            'data' => trans('agendamento.data'), 'hora' => trans('agendamento.hora'), 'escritorio' => trans('agendamento.escritorio')];
    $routeName = 'agendamentos';
    $page = trans('agendamento.agendamento_list');
    $page_create = trans('agendamento.agendamento');
    $list = [];

    $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 . '.resultadoPesquisa', ['page' => $page, 'columnList' => $columnList, 'list' => $list,
                'page_create' => $page_create, 'routeName' => $routeName, 'breadcrumb' => $breadcrumb]);
    
})->name('resultadoPesquisa');


//->middleware('auth')
