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); } } }
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); }
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; }