<?php

namespace App\Geo\Country;

use \App\Core\Template\Output as Output;
use \App\Geo\Country\Classes\Country as Country;

class CountryController extends \DefaultController{

    protected $_class   = Country::class;
    protected $_baseUrl = 'country';

    /**
    * Index
    *   Show the main Country list
    */
    function index(){
        $list = Array();

        for($i = 0; $i <= 10; $i++){
            $obj = Array();
            $obj['id'] = $i;
            $obj['value'] = md5($i);
            $obj['description'] = sha1($i);
            $list[] = $obj;
        }

        Output::render('index', Array('list' => $list));
    }

    /**
    * Create
    *
    * Render the main Country formulary
    */
    function create(){
        Output::render('form', ['id' => 0]);
    }

    /**
    * Store
    *
    * Store the param on the database
    * @param Country $country
    */
    function store(Country $country){

    }

    /**
    * Search
    *
    * Store the param on the database
    * @param Country $country
    */
    function search(){
    
    }

    /**
    * Show
    *
    * Render one register
    *
    * @param Country $country
    */
    function show(Country $country){

    }

    /**
    * Edit
    *
    * Render the formular for a database Country
    *
    * @param Country $country
    */
    function edit(Country $country){
        Output::render('form', $country);
    }

    /**
    * Update
    * Store the changes of the param on the database
    *
    * @param Country $country
    */
    function update(Country $country){

    }

    /**
    * Destroy
    * If the object has soft delete.
    *
    * @param Country $country
    */
    function destroy(Country $country){

    }

    /**
    * Purge
    * Remove object even with soft delete.
    *
    * @param Country $country
    */
    function purge(Country $country){

    }
    
    function raw(){
        var_dump( Country::findOne('25')->with(['states']) );
    }
}