Ejemplo n.º 1
0
 private function clearTableSchema($name)
 {
     if (preg_match('#m[\\d]+(Create|Alter)(?<table>[a-zA-Z][a-zA-Z0-9\\_]+)Table#i', $name, $matches)) {
         $table = strtolower(Strings::camelToSnake($matches['table']));
         $path = App::path('cache') . "/schema/" . DB::getDatabaseName() . "/{$table}.dat";
         if (file_exists($path)) {
             unlink($path);
         }
     }
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     if (isset($this->table)) {
         $table = $this->table;
     } else {
         $statements = explode('\\', get_called_class());
         $table = $statements[count($statements) - 1];
         $table = Strings::camelToSnake($table);
     }
     $this->initializeModel($table);
 }
Ejemplo n.º 3
0
    public static function generateModel($table, $class, array $properties, $namespace = null)
    {
        $content = str_replace('{{header}}', self::generateHeader($properties), self::getModelTemplate());
        $namespace = isset($namespace) ? "namespace {$namespace};" : "";
        $content = str_replace('{{namespace}}', $namespace, $content);
        $content = str_replace('{{model}}', $class, $content);
        $content = str_replace('{{table_name}}', $table === Strings::camelToSnake($class) ? "" : '
    protected $table = "' . $table . '";
', $content);
        return $content;
    }