A set of plugins to help on managing geographic information
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use App\Core\Template\Output as Output;
|
||||
use Routes\RouteCollection as RouteCollection;
|
||||
|
||||
//Menu itens
|
||||
RouteCollection::get('*', function() {
|
||||
Output::addOnSubmenu('geo', '/zone', "Localidades", "", ['class' => 'nav-link']);
|
||||
}, -10)->doIgnore();
|
||||
|
||||
RouteCollection::group("/zone", function(){
|
||||
RouteCollection::get ("/", "\App\Geo\Zone\ZoneController@index");
|
||||
RouteCollection::get ("/form", "\App\Geo\Zone\ZoneController@create");
|
||||
RouteCollection::post ("/", "\App\Geo\Zone\ZoneController@store");
|
||||
RouteCollection::post ("/search", "\App\Geo\Zone\ZoneController@search");
|
||||
RouteCollection::get ("/[i:id]", "\App\Geo\Zone\ZoneController@show");
|
||||
RouteCollection::get ("/[i:id]/edit", "\App\Geo\Zone\ZoneController@edit");
|
||||
RouteCollection::put ("/[i:id]/edit", "\App\Geo\Zone\ZoneController@update");
|
||||
RouteCollection::delete("/[i:id]", "\App\Geo\Zone\ZoneController@destroy");
|
||||
});
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Geo\Zone;
|
||||
|
||||
use \App\Core\Template\Output as Output;
|
||||
use \App\Geo\Zone\Classes\Zone as Zone;
|
||||
|
||||
class ZoneController {
|
||||
|
||||
/**
|
||||
* Index
|
||||
* Show the main Zone 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', $list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*
|
||||
* Render the main Zone formulary
|
||||
*/
|
||||
function create(){
|
||||
Output::render('form', ['id' => 0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store
|
||||
*
|
||||
* Store the param on the database
|
||||
* @param Zone $zone
|
||||
*/
|
||||
function store(Zone $zone){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Search
|
||||
*
|
||||
* Store the param on the database
|
||||
* @param Zone $zone
|
||||
*/
|
||||
function search(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show
|
||||
*
|
||||
* Render one register
|
||||
*
|
||||
* @param Zone $zone
|
||||
*/
|
||||
function show(Zone $zone){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit
|
||||
*
|
||||
* Render the formular for a database Zone
|
||||
*
|
||||
* @param Zone $zone
|
||||
*/
|
||||
function edit(Zone $zone){
|
||||
Output::render('form', $zone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update
|
||||
* Store the changes of the param on the database
|
||||
*
|
||||
* @param Zone $zone
|
||||
*/
|
||||
function update(Zone $zone){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy
|
||||
* If the object has soft delete.
|
||||
*
|
||||
* @param Zone $zone
|
||||
*/
|
||||
function destroy(Zone $zone){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge
|
||||
* Remove object even with soft delete.
|
||||
*
|
||||
* @param Zone $zone
|
||||
*/
|
||||
function purge(Zone $zone){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Geo\Zone\Classes;
|
||||
|
||||
use ORM\Entity as Entity;
|
||||
|
||||
class Zone extends Entity {
|
||||
|
||||
//const _idPolice = Array("type" => "", "min" => 0, "max" => 100000, "step" => 2);
|
||||
|
||||
const _tableName = "geo_zones";
|
||||
/*const _properties = Array(
|
||||
"id" => ['listable' => true, 'searcheble' => false, 'orderable' => false],
|
||||
"name" => ['listable' => true, 'searcheble' => true]);
|
||||
*/
|
||||
|
||||
//const _timestamps = true;
|
||||
//const _softdelete = true;
|
||||
|
||||
//const _connectionName = "";
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Schema\Wrapper as Wrapper;
|
||||
use App\Core\Sanity\MigratorController as Migrator;
|
||||
|
||||
function geo_zone_upgrade($pluginversion) {
|
||||
if ($pluginversion < "0.0.1") {
|
||||
$table = Wrapper::get_table("geo_zones");
|
||||
$table->addColumn("name", "string", Array("null" => false));
|
||||
$table->addColumn("city_id", "integer", Array("null" => false));
|
||||
$table->addSoftDelete();
|
||||
$table->addForeignKey('city_id', Wrapper::get_table('geo_cities'));
|
||||
$table->create();
|
||||
|
||||
Migrator::getInstance()->update_plugin_version("geo_zone", "1.0.0");
|
||||
return;
|
||||
}
|
||||
|
||||
//if ($pluginversion < "0.0.2") {
|
||||
//$table = Wrapper::get_table("geo_zones");
|
||||
//Migrator::getInstance()->update_plugin_version("geo_zone", "1.0.1");
|
||||
//return;
|
||||
//}
|
||||
}
|
||||
|
||||
function geo_zone_rollback($pluginversion) {
|
||||
if($pluginversion > "0.0.1"){
|
||||
$table = Wrapper::get_table("geo_zones");
|
||||
$table->drop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$lang["zone"]["module_name"] = "Zone";
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$lang["zone"]["module_name"] = "Zone";
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$plugin->name = "geo_zone";
|
||||
$plugin->version = "1.0.0";
|
||||
|
||||
$plugin->require = Array(
|
||||
Array("name" => "geo_params", "version" => "1.0.0"),
|
||||
Array("name" => "geo_country", "version" => "1.0.0"),
|
||||
Array("name" => "geo_state", "version" => "1.0.0"),
|
||||
Array("name" => "geo_city", "version" => "1.0.0")
|
||||
);
|
||||
@@ -0,0 +1,10 @@
|
||||
{{@ if( {{id}} ): @}}
|
||||
<form method="POST" action="/zone/{{id}}/edit">
|
||||
<input type="hidden" name="id" value="{{id}}" />
|
||||
<input type="hidden" name="_method" value="put" />
|
||||
{{@ else: @}}
|
||||
<form method="POST" action="/zone">
|
||||
<input type="hidden" name="id" value="" />
|
||||
{{@ endif; @}}
|
||||
|
||||
</form>
|
||||
@@ -0,0 +1,4 @@
|
||||
<a href='/zone/form' >Adicionar </a>
|
||||
<div class="table-responsive">
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user