/** * Run the migrations. * * @return void */ public function up() { Schema::table(DB_OBJECTS, function ($table) { $table->string('url')->nullable(); }); DB::table(DB_FIELDS)->where('name', 'slug')->delete(); //add slug column to all tables that don't have it $objects = DB::table(DB_OBJECTS)->get(); foreach ($objects as $object) { //add slug column if (Schema::hasColumn($object->name, 'slug')) { DB::table($object->name)->whereNull('slug')->update(['slug' => '']); DB::update('ALTER TABLE `' . $object->name . '` MODIFY `slug` VARCHAR(255) NOT NULL'); Schema::table($object->name, function ($table) { //$table->unique('slug'); }); } else { Schema::table($object->name, function ($table) { $table->string('slug'); //->unique(); }); //set slug values Slug::setForObject($object); } //add created_by column, not sure why this wasn't added earlier if (!Schema::hasColumn($object->name, 'created_by')) { Schema::table($object->name, function ($table) { $table->integer('created_by'); }); } } }
Route::get('/', array('as' => 'home', 'uses' => 'ObjectController@index')); Route::get('/logout', 'LoginController@getLogout'); Route::post('/upload/image', 'FileController@image'); # Test routes Route::get('/schema/save', 'ObjectController@saveSchema'); Route::get('/schema/load', 'ObjectController@loadSchema'); Route::get('/image/test', 'FileController@test'); Route::get('/slug/test', function () { $phrases = ['', 'and', 'this is a normal test', 'this is a really really really long test because it\'s amazing and great and am i at 50 YET???']; foreach ($phrases as $phrase) { echo '<p>' . $phrase . ' becomes <em>' . Slug::make($phrase, ['', 'normal-test', 'normal-test-1']) . '</em></p>'; } }); Route::get('/slug/object/{object_id}', function ($object_id) { $object = DB::table(DB_OBJECTS)->find($object_id); Slug::setForObject($object); die('object was ' . $object->name); }); Route::get('cleanup', function () { FieldController::cleanup(); FileController::findOrphans(); FileController::cleanup(); }); # Complex instance routing, optionally with linked_id for related objects Route::get('/{object_name}/delete/{instance_id}', 'InstanceController@delete'); Route::get('/{object_name}', 'InstanceController@index'); Route::get('/{object_name}/export', 'InstanceController@export'); Route::get('/{object_name}/create/{linked_id?}', 'InstanceController@create'); Route::post('/{object_name}/reorder', 'InstanceController@reorder'); Route::post('/{object_name}/{linked_id?}', 'InstanceController@store'); Route::get('/{object_name}/{instance_id}/{linked_id?}', 'InstanceController@edit');