| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <?php
- namespace App\Geo\State;
- use \App\Core\Template\Output as Output;
- use \App\Geo\State\Classes\State as State;
- class StateController
- {
- /**
- * Index
- * Show the main State 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('list', $list);
- }
- /**
- * Create
- *
- * Render the main State formulary
- */
- function create()
- {
- Output::setView('form', ['id' => 0]);
- Output::render();
- }
- /**
- * Store
- *
- * Store the param on the database
- * @param State $state
- */
- function store(State $state)
- {
- }
- /**
- * Search
- *
- * Store the param on the database
- * @param State $state
- */
- function search()
- {
- $states = State::findAll(['id', 'shortname']);
- $return = "<option value='0'>Selecione</option>";
- foreach ($states as $state) {
- if ($state->id == $_GET['value']) {
- $return .= "<option value='$state->id' selected>$state->shortname</option>";
- } else {
- $return .= "<option value='$state->id'>$state->shortname</option>";
- }
- }
- echo $return;
- }
- /**
- * Show
- *
- * Render one register
- *
- * @param State $state
- */
- function show(State $state)
- {
- \RR\Response::json($state)->send();
- }
- /**
- * Edit
- *
- * Render the formular for a database State
- *
- * @param State $state
- */
- function edit(State $state)
- {
- Output::setView('form', $state);
- Output::render();
- }
- /**
- * Update
- * Store the changes of the param on the database
- *
- * @param State $state
- */
- function update(State $state)
- {
- }
- /**
- * Destroy
- * If the object has soft delete.
- *
- * @param State $state
- */
- function destroy(State $state)
- {
- }
- /**
- * Purge
- * Remove object even with soft delete.
- *
- * @param State $state
- */
- function purge(State $state)
- {
- }
- function loadSelect()
- {
- //ddd(State::findMany(['country_id' => ['=', '25']])->get());
- Output::render(
- 'select',
- [
- 'states' => State::findMany(['country_id' => ['=', '25']])->get(),
- //'selected' => $_GET['value']
- ]
- );
- }
- }
|