Guest User

Untitled

a guest
Jan 19th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. Schema::create('posts', function (Blueprint $table) {
  2. $table->increments('id');
  3. $table->integer('user_id')->unsigned();
  4. $table->string('title');
  5. $table->string('slug')->unique();
  6. $table->string('image')->default('default.png');
  7. $table->text('body');
  8. $table->boolean('is_approved')->default(false);
  9. $table->boolean('status')->default(false);
  10. $table->integer('view_count')->default(0);
  11. $table->foreign('user_id')
  12. ->references('id')->on('users')
  13. ->onDelete('cascade')->unsigned()->index();
  14. $table->timestamps();
  15. });
  16.  
  17. Schema::create('users', function (Blueprint $table) {
  18. $table->increments('id');
  19. $table->integer('role_id')->default(2);
  20. $table->string('name');
  21. $table->string('username')->unique();
  22. $table->string('email')->unique();
  23. $table->string('image')->default('default.png');
  24. $table->timestamp('email_verified_at')->nullable();
  25. $table->string('password');
  26. $table->text('about')->nullable();
  27. $table->rememberToken();
  28. $table->timestamps();
  29. });
  30.  
  31. Schema::table('post_users', function (Blueprint $table) {
  32. $table->integer('post_id')->unsigned();
  33. $table->integer('user_id');
  34. $table->foreign('post_id')
  35. ->references('id')->on('posts')
  36. ->onDelete('cascade')->unsigned()->index();
  37. });
Add Comment
Please, Sign In to add comment