2016_01_04_173148_create_admin_tables.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateAdminTables extends Migration
  6. {
  7. /**
  8. * {@inheritdoc}
  9. */
  10. public function getConnection()
  11. {
  12. return config('admin.database.connection') ?: config('database.default');
  13. }
  14. /**
  15. * Run the migrations.
  16. *
  17. * @return void
  18. */
  19. public function up()
  20. {
  21. Schema::create(config('admin.database.users_table'), function (Blueprint $table) {
  22. $table->increments('id');
  23. $table->string('username', 190)->unique();
  24. $table->string('password', 60);
  25. $table->string('name');
  26. $table->string('avatar')->nullable();
  27. $table->string('remember_token', 100)->nullable();
  28. $table->timestamps();
  29. });
  30. Schema::create(config('admin.database.menu_table'), function (Blueprint $table) {
  31. $table->increments('id');
  32. $table->integer('parent_id')->default(0);
  33. $table->integer('order')->default(0);
  34. $table->string('title', 50);
  35. $table->string('icon', 50);
  36. $table->string('uri')->nullable();
  37. $table->timestamps();
  38. });
  39. }
  40. /**
  41. * Reverse the migrations.
  42. *
  43. * @return void
  44. */
  45. public function down()
  46. {
  47. Schema::dropIfExists(config('admin.database.users_table'));
  48. Schema::dropIfExists(config('admin.database.menu_table'));
  49. }
  50. }