예제 #1
0
 public static function getScanDir($directory)
 {
     $content = scandir($directory);
     array_shift($content);
     array_shift($content);
     $result = ['folders' => [], 'files' => []];
     $temp = '';
     foreach ($content as $some) {
         $temp = \Str\Str::load($directory)->setEnding(DIRECTORY_SEPARATOR)->append($some);
         if (is_file($temp)) {
             $result['files'][] = $temp;
         } else {
             $result['folders'][] = $temp;
         }
     }
     return $content;
 }
예제 #2
0
<?php

echo '<?php';
?>

class Model_<?php 
echo \Str\Str::load($table)->toLowerCase()->toUpperCaseFirst()->get();
?>
 extends ORM
{

protected $_table_name = '<?php 
echo \Str\Str::load($table)->toLowerCase()->get();
?>
';
    
}
예제 #3
0
 public static function getManyToManyRelationArray($label, $options, $table, $own_key, $foreign_key, $type = 'multiselect', $mergeParams = [])
 {
     //creating table in database if need
     $createIfNotExists = '
       CREATE TABLE IF NOT EXISTS `' . $table . '` (
         `' . $own_key . '` INT UNSIGNED NOT NULL ,
         `' . $foreign_key . '` INT UNSIGNED NOT NULL ,
         UNIQUE (`' . $own_key . '`, `' . $foreign_key . '`)) ENGINE = InnoDB';
     DB::query(Database::INSERT, $createIfNotExists)->execute();
     $modelClassName = \Str\Str::load($table)->remove('^[^_]+_')->toLowerCase()->toUpperCaseFirst()->prepend('Model_')->get();
     //creating model file if need
     if (!class_exists($modelClassName)) {
         $modelPath = APPPATH . 'classes' . DIRECTORY_SEPARATOR . 'Model' . DIRECTORY_SEPARATOR . \Zver\StringHelper::load($modelClassName)->remove('^[^_]+_')->get() . '.php';
         if (!file_exists($modelPath)) {
             file_put_contents($modelPath, View::factory('system/ORM_Template')->set('table', \Zver\StringHelper::load($table)->remove('^[^_]+_')->toLowerCase()->toUpperCaseFirst()->get()));
         }
     }
     $params = ['dont_select' => true, 'label' => $label, 'type' => $type, 'options' => $options, 'get_current_value' => function () use($table, $own_key, $foreign_key) {
         $request = Request::initial();
         $id = $request->param('primary');
         $current = DB::select($foreign_key)->from($table)->where($own_key, '=', $id)->execute()->as_array($foreign_key, $foreign_key);
         return $current;
     }];
     return array_merge($params, $mergeParams);
 }