public function login() { if (Request::isPost()) { // validation example code helper\Session::doLogin($this->request, $this->validation); } else { // your code } }
public function run() { $post = Request::post(); $post['table'] = Helper::parseName($post['table'], 1); $controller = \Demo\Helper\ThemeBuilder::generateController($post); $helper = \Demo\Helper\ThemeBuilder::generateHelper($post); $model = \Demo\Helper\ThemeBuilder::generateModel($post); $controllerFile = __DIR__ . DIRECTORY_SEPARATOR . ucfirst($post['table']) . '.php'; $helperFile = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Helper' . DIRECTORY_SEPARATOR . ucfirst($post['table']) . '.php'; $modelFile = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Model' . DIRECTORY_SEPARATOR . ucfirst($post['table']) . '.php'; if (file_exists($controllerFile)) { Error::echoJson(-1, 'controller file ' . $controllerFile . ' exits already!'); } if (file_exists($helperFile)) { Error::echoJson(-1, 'helper file ' . $helperFile . ' exits already!'); } if (file_exists($modelFile)) { Error::echoJson(-1, 'model file ' . $modelFile . ' exits already!'); } file_put_contents($controllerFile, $controller); file_put_contents($helperFile, $helper); file_put_contents($modelFile, $model); Error::echoJson(-1, 'Success!'); }