1: <?php
2:
3: use Illuminate\Database\Schema\Blueprint;
4: use Illuminate\Database\Migrations\Migration;
5:
6: class CreateTablesTable extends Migration {
7:
8: 9: 10: 11: 12: 13:
14: public function up()
15: {
16: if (!Schema::hasTable('_db_tables'))
17: {
18: Schema::create('_db_tables', function ($table)
19: {
20: $table->increments('id')->unique();
21: $table->string('name', 100)->unique();
22: $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
23: $table->timestamp('updated_at')->default('0000-00-00 00:00:00');
24: });
25: }
26: }
27:
28: 29: 30: 31: 32: 33:
34: public function down()
35: {
36: Schema::dropIfExists('_db_tables');
37: }
38:
39: 40: 41: 42: 43:
44: private function __makeLabel($name)
45: {
46: return ucwords(str_replace('_', ' ', $name));
47: }
48:
49: 50: 51:
52: private function __getFieldType($fieldType)
53: {
54: $start = strpos($fieldType, '(');
55: if ($start > 0)
56: {
57: $fieldType = substr($fieldType, 0, $start);
58: $this->__log("success", "fieldtype : $fieldType");
59: }
60: return $fieldType;
61: }
62:
63: 64: 65:
66: private function __getFieldLength($fieldType)
67: {
68: $start = strpos($fieldType, '(') + 1;
69: $len = null;
70: if ($start > 0)
71: {
72: $count = strpos($fieldType, ')') - $start;
73: $len = substr($fieldType, $start, $count);
74:
75: }
76:
77: return $len;
78: }
79:
80: 81: 82:
83: private function __getFieldWidth($fieldType, $fieldLength)
84: {
85: return 100;
86: }
87:
88: 89: 90:
91: private function __getFieldWidget($fieldType, $fieldLength)
92: {
93: return "";
94: }
95:
96: }
97: