<?php

use App\Core\Template\Output as Output;
use Routes\RouteCollection as RouteCollection;

use \App\Geo\City\Classes\City as City;

//Menu itens
RouteCollection::get('*', function () {
    //Output::addMenu('/city', 'city', "<i class='fa fa-fa-cubes'></i>", ['class' => 'nav-link']);
    Output::addOnSubmenu('geo', '/city', 'Cidades', "", ['class' => 'nav-link']);
}, -10)->doIgnore();

RouteCollection::group("/city", function () {
    RouteCollection::get("/",            "\App\Geo\City\CityController@index");
    RouteCollection::get("/table",       "\App\Geo\City\CityController@table");
    RouteCollection::post("/table",       "\App\Geo\City\CityController@searchTable");
    RouteCollection::get("/form",        "\App\Geo\City\CityController@create");
    RouteCollection::post("/",            "\App\Geo\City\CityController@store");
    RouteCollection::post("/search",      "\App\Geo\City\CityController@search");
    RouteCollection::get("/[i:id]",      "\App\Geo\City\CityController@show");
    RouteCollection::get("/[i:id]/edit", "\App\Geo\City\CityController@edit");
    RouteCollection::put("/[i:id]/edit", "\App\Geo\City\CityController@update");
    RouteCollection::delete("/[i:id]",      "\App\Geo\City\CityController@destroy");

    RouteCollection::get("/test", function () {
        $city = City::findOne(180)->with(['country']);
        $form = file_get_contents(__DIR__ . '/views/form.mustache');

        $m = new Mustache_Engine(array('entity_flags' => ENT_QUOTES));
        echo $m->render($form, $city); // "Hello World!"


    });
});
