parent
01540e23f9
commit
cc8e7529db
@ -0,0 +1,37 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace prj\{{.Root}}\logic\{{.Subfolder}}; |
||||
|
||||
use \tts\safer_io as SafeIO; |
||||
|
||||
class {{.File}}_logic { |
||||
|
||||
public static function {{.Method}}(array & $input): void { |
||||
$model = new \prj\{{.Root}}\models\{{.Subfolder}}\{{.File}}_model(\tts\main\registry::get('db')); |
||||
|
||||
$submitted = true; |
||||
foreach(SafeIO::logic_sanitize($input) as $data) { |
||||
if (SafeIO::required_fields_were_NOT_all_submitted($data)) { |
||||
$submitted = false; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
$input['submitted'] = $submitted; |
||||
|
||||
if ($submitted) { |
||||
$model->init_demo_table(); // Create Table if NOT exists! |
||||
$model->populate(10); // INSERT 10 random rows of data |
||||
|
||||
$success = $model->save_index($input); // Save data from Request Data |
||||
$input['model'] = ($success===true) ? |
||||
$model->get_index(15) : |
||||
$model->get_index(0); |
||||
} else { |
||||
$input['model'] = $model->get_index(0); |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,37 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace prj\mockup\logic\app; |
||||
|
||||
use \tts\safer_io as SafeIO; |
||||
|
||||
class home_logic { |
||||
|
||||
public static function name_demo(array & $input): void { |
||||
$model = new \prj\mockup\models\app\home_model(\tts\main\registry::get('db')); |
||||
|
||||
$submitted = true; |
||||
foreach(SafeIO::logic_sanitize($input) as $data) { |
||||
if (SafeIO::required_fields_were_NOT_all_submitted($data)) { |
||||
$submitted = false; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
$input['submitted'] = $submitted; |
||||
|
||||
if ($submitted) { |
||||
$model->init_name_demo_table(); // Create Table if NOT exists! |
||||
$model->populate(10); // INSERT 10 random rows of data |
||||
|
||||
$success = $model->save_new_user($input); // Save data from Request Data |
||||
$input['model'] = ($success===true) ? |
||||
$model->get_users(15) : |
||||
$model->get_users(0); |
||||
} else { |
||||
$input['model'] = $model->get_users(0); |
||||
} |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue