Common functionalities
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Common\Defaults;
|
||||
|
||||
use \App\Core\Template\Output as Output;
|
||||
use \App\Common\Defaults\Classes\Defaults as Defaults;
|
||||
|
||||
class DefaultsController {
|
||||
|
||||
/**
|
||||
* Index
|
||||
* Show the main Defaults list
|
||||
*/
|
||||
function index(){
|
||||
Output::setView('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::addValue('list', $list );
|
||||
Output::render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*
|
||||
* Render the main Defaults formulary
|
||||
*/
|
||||
function create(){
|
||||
Output::setView('form', ['id' => 0]);
|
||||
Output::render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Store
|
||||
*
|
||||
* Store the param on the database
|
||||
* @param Defaults $defaults
|
||||
*/
|
||||
function store(Defaults $defaults){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Search
|
||||
*
|
||||
* Store the param on the database
|
||||
* @param Defaults $defaults
|
||||
*/
|
||||
function search(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show
|
||||
*
|
||||
* Render one register
|
||||
*
|
||||
* @param Defaults $defaults
|
||||
*/
|
||||
function show(Defaults $defaults){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit
|
||||
*
|
||||
* Render the formular for a database Defaults
|
||||
*
|
||||
* @param Defaults $defaults
|
||||
*/
|
||||
function edit(Defaults $defaults){
|
||||
Output::setView('form', $defaults);
|
||||
Output::render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update
|
||||
* Store the changes of the param on the database
|
||||
*
|
||||
* @param Defaults $defaults
|
||||
*/
|
||||
function update(Defaults $defaults){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy
|
||||
* If the object has soft delete.
|
||||
*
|
||||
* @param Defaults $defaults
|
||||
*/
|
||||
function destroy(Defaults $defaults){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge
|
||||
* Remove object even with soft delete.
|
||||
*
|
||||
* @param Defaults $defaults
|
||||
*/
|
||||
function purge(Defaults $defaults){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use App\Core\Template\Output as Output;
|
||||
use Routes\RouteCollection as RouteCollection;
|
||||
|
||||
//Menu itens
|
||||
RouteCollection::get('*', function() {
|
||||
//Output::addMenu('/defaults', 'defaults', "<i class='fa fa-fa-cubes'></i>", ['class' => 'nav-link']);
|
||||
Output::addOnSubmenu('config', '/defaults', "Padrões", "", ['class' => 'nav-link']);
|
||||
}, -10)->doIgnore();
|
||||
|
||||
RouteCollection::group("/defaults", function(){
|
||||
RouteCollection::get ("/", "\App\Common\Defaults\DefaultsController@index");
|
||||
RouteCollection::get ("/form", "\App\Common\Defaults\DefaultsController@create");
|
||||
RouteCollection::post ("/", "\App\Common\Defaults\DefaultsController@store");
|
||||
RouteCollection::post ("/search", "\App\Common\Defaults\DefaultsController@search");
|
||||
RouteCollection::get ("/[i:id]", "\App\Common\Defaults\DefaultsController@show");
|
||||
RouteCollection::get ("/[i:id]/edit", "\App\Common\Defaults\DefaultsController@edit");
|
||||
RouteCollection::put ("/[i:id]/edit", "\App\Common\Defaults\DefaultsController@update");
|
||||
RouteCollection::delete("/[i:id]", "\App\Common\Defaults\DefaultsController@destroy");
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Common\Defaults\Classes;
|
||||
|
||||
use ORM\Entity as Entity;
|
||||
|
||||
class Defaults extends Entity {
|
||||
|
||||
const _tableName = "defaultss";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Schema\Wrapper as Wrapper;
|
||||
use App\Core\Sanity\MigratorController as Migrator;
|
||||
|
||||
function common_defaults_upgrade($pluginversion) {
|
||||
if ($pluginversion < "0.0.1") {
|
||||
$table = Wrapper::get_table("common_system_defaults");
|
||||
$table->addColumn("module", "string", Array("null" => true));
|
||||
$table->addColumn("table", "string", Array("null" => true));
|
||||
$table->addColumn("key", "string", Array("null" => false));
|
||||
$table->addColumn("value", "string", Array("null" => false));
|
||||
$table->create();
|
||||
|
||||
$table = Wrapper::get_table("common_user_defaults");
|
||||
$table->addColumn("user_id", "integer", Array("null" => false));
|
||||
$table->addColumn("module", "string", Array("null" => true));
|
||||
$table->addColumn("table", "string", Array("null" => true));
|
||||
$table->addColumn("key", "string", Array("null" => false));
|
||||
$table->addColumn("value", "string", Array("null" => false));
|
||||
$table->addForeignKey('user_id', Wrapper::get_table('core_auth_user'));
|
||||
|
||||
Migrator::getInstance()->update_plugin_version("common_defaults", "1.0.0");
|
||||
return;
|
||||
}
|
||||
|
||||
//if ($pluginversion < "0.0.2") {
|
||||
//$table = Wrapper::get_table("common_defaultss");
|
||||
//Migrator::getInstance()->update_plugin_version("common_defaults", "1.0.1");
|
||||
//return;
|
||||
//}
|
||||
}
|
||||
|
||||
function common_defaults_rollback($pluginversion) {
|
||||
if($pluginversion > "0.0.1"){
|
||||
$table = Wrapper::get_table("common_defaultss");
|
||||
$table->drop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$lang["defaults"]["module_name"] = "Defaults";
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$lang["defaults"]["module_name"] = "Defaults";
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
$plugin->name = "common_defaults";
|
||||
$plugin->version = "0.0.0";
|
||||
|
||||
$plugin->require = Array(
|
||||
Array("name" => "core_auth", "version" => "1.0.0")
|
||||
);
|
||||
@@ -0,0 +1,10 @@
|
||||
{{@ if( {{id}} ): @}}
|
||||
<form method="POST" action="/defaults/{{id}}/edit">
|
||||
<input type="hidden" name="id" value="{{id}}" />
|
||||
<input type="hidden" name="_method" value="put" />
|
||||
{{@ else: @}}
|
||||
<form method="POST" action="/defaults">
|
||||
<input type="hidden" name="id" value="" />
|
||||
{{@ endif; @}}
|
||||
|
||||
</form>
|
||||
@@ -0,0 +1,4 @@
|
||||
<a href='/defaults/form' >Adicionar </a>
|
||||
<div class="table-responsive">
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user