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

if(env('APP_ENV') === 'production' || env('APP_ENV') === 'testing'){
    URL::forceScheme('https');
}

Route::group(['middleware' => 'permissions:SHARE'], function(){
    Route::get('/', function () {
        return view('home');
    })->name('home');

    Auth::routes();

    //authenticated user only pages
    Route::group(['middleware' => 'auth'], function() {
        Route::get('/mode', function () {
            if(session("adminmode")){
                session()->put("adminmode",false);
                return redirect()->back();
            }else{
                session()->put("adminmode",true);
                return redirect()->back();
            }
        })->name('mode');
    });

    Route::resource('users','UserController');
    Route::resource('roles','RoleController');
    Route::resource('recipes','RecipeController');
});
