Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1) users_level
- Schema::create('levels', function($table)
- {
- $table->increments('id')->unsigned();
- $table->string('level');
- $table->engine = 'InnoDB';
- });
- DB::insert('insert into levels (id, level) values (?, ?)', array(1, 'Admin'));
- DB::insert('insert into levels (id, level) values (?, ?)', array(2, 'Editor'));
- DB::insert('insert into levels (id, level) values (?, ?)', array(3, 'User'));
- // 2) users
- Schema::create('users', function($table)
- {
- $table->increments('id')->unsigned();
- $table->string('username'); $table->unique('username');
- $table->string('password');
- $table->string('email'); $table->unique('email');
- $table->string('avatar', '1024');
- $table->boolean('newsletter');
- $table->timestamps();
- $table->integer('level_id')->unsigned(); //Foreign key unsigned
- $table->foreign('level_id')->references('id')->on('levels');
- $table->engine = 'InnoDB';
- });
- // 3) news
- Schema::create('news', function($table)
- {
- $table->increments('id')->unsigned();;
- $table->string('title', '512');
- $table->string('url_title', '1024');
- $table->text('short_news');
- $table->text('full_news');
- $table->timestamps();
- $table->integer('user_id')->unsigned(); //Foreign key unsigned
- $table->foreign('user_id')->references('id')->on('users');
- $table->engine = 'InnoDB';
- });
- // 4) categories
- Schema::create('categories', function($table)
- {
- $table->increments('id')->unsigned();;
- $table->string('category'); $table->unique('category');
- $table->string('icon', '1024');
- $table->timestamps();
- $table->engine = 'InnoDB';
- });
- // 5) comments
- Schema::create('comments', function($table)
- {
- $table->increments('id')->unsigned();;
- $table->text('comment');
- $table->timestamps();
- $table->integer('news_id')->unsigned(); //Foreign key unsigned
- $table->foreign('news_id')->references('id')->on('news');
- $table->integer('user_id')->unsigned(); //Foreign key unsigned
- $table->foreign('user_id')->references('id')->on('users');
- $table->engine = 'InnoDB';
- });
- // 6) categories_news
- Schema::create('categories_news', function($table)
- {
- $table->integer('categories_id')->unsigned(); //Foreign key unsigned
- $table->foreign('categories_id')->references('id')->on('categories');
- $table->integer('news_id')->unsigned(); //Foreign key unsigned
- $table->foreign('news_id')->references('id')->on('news');
- $table->engine = 'InnoDB';
- });
- // 7) images
- Schema::create('images', function($table)
- {
- $table->increments('id')->unsigned();;
- $table->string('image', '1024');
- $table->timestamps();
- $table->engine = 'InnoDB';
- });
- // 8) configurations
- Schema::create('configurations', function($table)
- {
- $table->increments('id')->unsigned();;
- $table->boolean('active_comments');
- $table->integer('news_per_page');
- $table->timestamps();
- $table->engine = 'InnoDB';
- });
Advertisement
Add Comment
Please, Sign In to add comment