Skip to content

Commit 81dfb79

Browse files
committed
More scheme updates
1 parent 698b05a commit 81dfb79

23 files changed

+798
-36
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@
6767
[submodule "public/vendor/Gallery"]
6868
path = public/vendor/Gallery
6969
url = [email protected]:blueimp/Gallery.git
70+
[submodule "public/vendor/jsPlumb"]
71+
path = public/vendor/jsPlumb
72+
url = [email protected]:sporritt/jsPlumb.git

app/controllers/ProjectController.php

Lines changed: 194 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,202 @@ public function getIndex()
99
$this->setViewData('projects', $projects);
1010
}
1111

12+
public function getCreate()
13+
{
14+
// get user groups
15+
16+
$this->setViewData('owners', array('user:' . Auth::user()->id => 'User: ' . Auth::user()->username));
17+
}
18+
19+
public function postCreate()
20+
{
21+
$input = e_array(Input::all());
22+
23+
if ($input != null) {
24+
$owner = explode(':', $input['owner']);
25+
26+
$project = new Project;
27+
$project->name = $input['name'];
28+
$project->privateFlag = isset($input['privateFlag']) ? $input['privateFlag'] : '0';
29+
$project->ownerType = $owner[0];
30+
$project->ownerId = $owner[1];
31+
$project->creatorId = Auth::user()->id;
32+
33+
$this->checkErrorsSave($project);
34+
}
35+
36+
return $this->redirect('/project');
37+
}
38+
39+
public function getCreateTable($projectId)
40+
{
41+
$project = Project::find($projectId);
42+
$engine = array('myisam' => 'MyiSAM', 'innodb' => 'InnoDB');
43+
$template = Template::all();
44+
45+
Menu::setItemList('main', new Menu\Items\ItemList);
46+
47+
Menu::handler('main')
48+
->add('/', 'Home')
49+
->add('javascript:void(0);', $project->name . ' Scheme', Menu::items()
50+
->add('/project/buildAll/' . $project->id, 'Full project build')
51+
->add('/project/buildAllModels/' . $project->id, 'Build all modles')
52+
->add('/project/buildAllMigration/' . $project->id, 'Build all migrations')
53+
->add('/project/buildAllSeeds/' . $project->id, 'Build all seeds')
54+
->add('/project/builds/' . $project->id, 'Project Builds')
55+
)
56+
->add('/project/create-table/' . $project->id, 'Add Table');
57+
58+
$this->setMenu();
59+
60+
$this->setViewData('template', $template->lists('name', 'id'));
61+
$this->setViewData('engine', $engine);
62+
$this->setViewData('project', $project);
63+
}
64+
65+
public function postCreateTable()
66+
{
67+
$input = e_array(Input::all());
68+
69+
if ($input != null) {
70+
$project = new Table;
71+
$project->projectId = $input['projectId'];
72+
$project->name = $input['name'];
73+
$project->className = $input['className'];
74+
$project->namespace = $input['namespace'];
75+
$project->timestampsFlag = isset($input['timestampsFlag']) ? $input['timestampsFlag'] : 0;
76+
$project->softDeletesFlag = isset($input['softDeletesFlag']) ? $input['softDeletesFlag'] : 0;
77+
$project->tableTemplateId = $input['templateId'];
78+
$project->postionLeft = 30;
79+
$project->postionTop = 60;
80+
$project->extends = $input['extends'];
81+
82+
$this->checkErrorsSave($project);
83+
}
84+
85+
return $this->redirect('/project/view/' . $input['projectId']);
86+
}
87+
88+
public function getCreateColumn($tableId)
89+
{
90+
$columnTypes = Column_Type::all();
91+
92+
$columnAttributes = [
93+
'NONE' => 'None',
94+
// 'BINARY' => '',
95+
'UNSIGNED' => 'Unsigned',
96+
// 'UNSIGNED ZEROFILL' => ''
97+
];
98+
99+
$indexes = [
100+
'NONE' => 'None',
101+
'INDEX' => 'Index',
102+
'PRIMARY_KEY' => 'Primary Key',
103+
'UNIQUE' => 'Unique'
104+
];
105+
106+
$this->setViewData('columnAttributes', $columnAttributes);
107+
$this->setViewData('indexes', $indexes);
108+
$this->setViewData('columnTypes', $columnTypes->lists('name', 'id'));
109+
$this->setViewData('tableId', $tableId);
110+
}
111+
112+
public function postCreateColumn()
113+
{
114+
$input = e_array(Input::all());
115+
116+
if ($input != null) {
117+
$table = Table::find((int) $input['tableId']);
118+
119+
$column = new Column;
120+
$column->tableId = $table->id;
121+
$column->name = $input['name'];
122+
$column->typeId = $input['typeId'];
123+
$column->defaultValue = $input['defaultValue'];
124+
$column->value = $input['value'];
125+
$column->attribute = $input['attribute']; // Should this be an unsigned flag?
126+
$column->index = $input['index'];
127+
$column->nullableFlag = isset($input['nullableFlag']) ? $input['nullableFlag'] : 0;
128+
$column->autoIncrementFlag = isset($input['autoIncrementFlag']) ? $input['autoIncrementFlag'] : 0;
129+
$column->fillableFlag = isset($input['fillableFlag']) ? $input['fillableFlag'] : 0;
130+
$column->visibleFlag = isset($input['visibleFlag']) ? $input['visibleFlag'] : 0;
131+
$column->guardedFlag = isset($input['guardedFlag']) ? $input['guardedFlag'] : 0;
132+
$column->hiddenFlag = isset($input['hiddenFlag']) ? $input['hiddenFlag'] : 0;
133+
$column->order = count($table->columns);
134+
135+
$this->checkErrorsSave($column);
136+
}
137+
138+
return $this->redirect('/project/view/' . $table->projectId);
139+
}
140+
12141
public function getView($scheme)
13142
{
14-
$scheme = Project::find($scheme);
143+
// eager load data needed to generate page.
144+
$scheme = Project::with([
145+
'tables',
146+
'tables.columns' => function ($query) {
147+
$query->orderBy('order', 'asc');
148+
},
149+
'tables.columns.type',
150+
'tables.template',
151+
'tables.local',
152+
'tables.local.type',
153+
'tables.foreign',
154+
'tables.foreign.type',
155+
'tables.through',
156+
'tables.through.type'
157+
])
158+
->find($scheme);
159+
160+
Menu::setItemList('main', new Menu\Items\ItemList);
161+
15162
Menu::handler('main')
16-
->add('javascript:void(0);', $scheme->name, Menu::items()
17-
->add('/scheme/buildAll', 'Full project build')
18-
->add('/scheme/buildAllModels', 'Build all modles')
19-
->add('/scheme/buildAllMigration', 'Build all migrations')
20-
->add('/scheme/buildAllSeeds', 'Build all seeds'));
163+
->add('/', 'Home')
164+
->add('javascript:void(0);', $scheme->name . ' Scheme', Menu::items()
165+
->add('/project/buildAll/' . $scheme->id, 'Full project build')
166+
->add('/project/buildAllModels/' . $scheme->id, 'Build all modles')
167+
->add('/project/buildAllMigration/' . $scheme->id, 'Build all migrations')
168+
->add('/project/buildAllSeeds/' . $scheme->id, 'Build all seeds')
169+
->add('/project/builds/' . $scheme->id, 'Project Builds')
170+
)
171+
->add('/project/create-table/' . $scheme->id, 'Add Table');
172+
173+
$this->setMenu();
174+
175+
$this->setViewData('scheme', $scheme);
176+
}
177+
178+
public function postUpdateTableLocation()
179+
{
180+
$input = Input::all();
181+
182+
$input['id'] = str_replace('dbtable_', '', $input['id']);
183+
184+
$table = Table::find((int) $input['id']);
185+
$table->postionLeft = (int) $input['postionLeft'];
186+
$table->postionTop = (int) $input['postionTop'];
187+
$table->save();
188+
189+
// return true;
190+
}
191+
192+
public function postUpdateTableOrder()
193+
{
194+
$input = Input::all();
195+
196+
$columns = explode(',', $input['order']);
197+
foreach ($columns as $key => $column) {
198+
$column = Column::find($column);
199+
$column->order = $key;
200+
$column->save();
201+
}
202+
203+
// return true;
204+
}
205+
206+
public function postUpdateColumnOrder($table, $order)
207+
{
208+
21209
}
22210
}

app/controllers/SchemeController.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/database/migrations/2014_04_28_035631_create_columns_table.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ public function up()
1111
$table->increments('id');
1212
$table->integer('tableId')->index();
1313
$table->string('name', 150);
14-
$table->text('description');
1514
$table->integer('typeId')->index();
1615
$table->text('defaultValue');
1716
$table->text('value');
18-
$table->text('collation');
1917
$table->enum('attribute', array('NONE', 'BINARY', 'UNSIGNED', 'UNSIGNED ZEROFILL'));
2018
$table->enum('index', array('NONE', 'INDEX', 'PRIMARY_KEY', 'UNIQUE'));
2119
$table->tinyInteger('nullableFlag')->default(0);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use Illuminate\Database\Schema\Blueprint;
4+
use Illuminate\Database\Migrations\Migration;
5+
6+
class CreateFailedJobsTable extends Migration {
7+
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::create('failed_jobs', function(Blueprint $table)
16+
{
17+
$table->increments('id');
18+
$table->text('connection');
19+
$table->text('queue');
20+
$table->text('payload');
21+
$table->timestamp('failed_at');
22+
});
23+
}
24+
25+
/**
26+
* Reverse the migrations.
27+
*
28+
* @return void
29+
*/
30+
public function down()
31+
{
32+
Schema::drop('failed_jobs');
33+
}
34+
35+
}

app/database/migrations/2014_04_28_035631_create_relationships_table.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public function up()
1818
$table->integer('throughKeyId')->nullable()->index();
1919
$table->integer('typeId')->index();
2020
$table->tinyInteger('namespaceFlag')->default(0);
21-
$table->string('extraMethods', 150);
21+
$table->string('extraMethods', 150)->nullable();
22+
$table->tinyInteger('requireKeysFlag')->default(0);
23+
$table->tinyInteger('errorCheckingFlag')->default(0);
2224
$table->timestamps();
2325
$table->softDeletes();
2426
});

app/database/migrations/2014_04_28_035631_create_tables_table.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,16 @@ public function up()
1010
Schema::create('tables', function(Blueprint $table) {
1111
$table->increments('id');
1212
$table->integer('projectId')->index();
13-
$table->string('tableName', 150)->index();
14-
$table->string('description', 150);
13+
$table->string('name', 150)->index();
1514
$table->string('className', 150);
1615
$table->string('namespace', 150)->nullable();
1716
$table->string('extends', 150)->nullable();
1817
$table->tinyInteger('timestampsFlag')->default(0);
1918
$table->tinyInteger('softDeletesFlag')->default(0);
20-
$table->enum('engine', array('MyISAM', 'InnoDB'));
21-
$table->string('collation', 150);
22-
$table->string('partition', 150);
23-
$table->integer('parentId')->nullable()->index();
19+
$table->enum('engine', array('myisam', 'innodb'));
2420
$table->integer('tableTemplateId')->index();
21+
$table->integer('postionLeft');
22+
$table->integer('postionTop');
2523
$table->timestamps();
2624
$table->softDeletes();
2725
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
6+
class CreateRelationshipTypesTable extends Migration {
7+
8+
public function up()
9+
{
10+
Schema::create('relationship_types', function(Blueprint $table) {
11+
$table->increments('id');
12+
$table->string('name', 50);
13+
$table->string('keyName', 50)->index();
14+
$table->timestamps();
15+
$table->softDeletes();
16+
});
17+
}
18+
19+
public function down()
20+
{
21+
Schema::drop('relationship_types');
22+
}
23+
}

0 commit comments

Comments
 (0)