Guest User

Untitled

a guest
Feb 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <?php
  2.  
  3. use Illuminate\Support\Facades\Schema;
  4. use Illuminate\Database\Schema\Blueprint;
  5. use Illuminate\Database\Migrations\Migration;
  6.  
  7. class CreateRolesTable extends Migration
  8. {
  9. /**
  10. * Run the migrations.
  11. *
  12. * @return void
  13. */
  14. public function up()
  15. {
  16. Schema::create('roles', function (Blueprint $table) {
  17. $table->increments('id');
  18. $table->string('name');
  19. $table->timestamps();
  20. });
  21.  
  22. //create 3 roles records
  23. $rows = [
  24. [
  25. 'id'=>1,
  26. 'name' => 'administrator'
  27. ],
  28. [
  29. 'id'=>2,
  30. 'name' => 'author'
  31. ],
  32. [
  33. 'id'=>3,
  34. 'name' => 'subscriber'
  35. ]
  36. ];
  37. // insert records
  38. DB::table('roles')->insert($rows);
  39. }
  40.  
  41. /**
  42. * Reverse the migrations.
  43. *
  44. * @return void
  45. */
  46. public function down()
  47. {
  48. Schema::dropIfExists('roles');
  49. }
  50. }
Add Comment
Please, Sign In to add comment