AdminSeeder.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Database\Seeders\Backend;
  3. use Database\Seeders\BaseSeeder;
  4. use Illuminate\Support\Facades\DB;
  5. use Illuminate\Support\Facades\Hash;
  6. use Illuminate\Support\Str;
  7. use Txj\Elastic\Facades\Eav;
  8. use Txj\Elastic\Facades\ES;
  9. class AdminSeeder extends BaseSeeder
  10. {
  11. public function getColumnData()
  12. {
  13. return [
  14. 'username' => ['type' => 'string_60', 'title' => '账号名称'],
  15. 'real_username' => ['type' => 'string_60', 'title' => '真实姓名'],
  16. 'avatar' => ['type' => 'string', 'title' => '头像', 'is_null' => 1],
  17. 'roles' => ['type' => 'json', 'title' => '角色', 'is_null' => 1],
  18. 'unionid' => ['type' => 'string_60', 'title' => '微信unionid'],
  19. 'status' => ['type' => 'string_60', 'title' => '状态', 'remark' => '1 启用 2 禁用'],
  20. 'remark' => ['type' => 'string', 'title' => '备注'],
  21. ];
  22. }
  23. /**
  24. * 初始化内容
  25. */
  26. public function init()
  27. {
  28. DB::table($this->schema)->insert([
  29. 'mid' => Str::random(12),
  30. 'created_at' => time(),
  31. 'updated_at' => time(),
  32. 'username' => 'tty',
  33. 'real_username' => '李磊',
  34. 'avatar' => '',
  35. 'roles' => json_encode([1, 2]),
  36. 'unionid' => '',
  37. 'status' => 1,
  38. 'remark' => '',
  39. ]);
  40. }
  41. /**
  42. * Run the database seeds.
  43. *
  44. * @return void
  45. */
  46. public function run()
  47. {
  48. $this->schema = 'admin';
  49. $this->title = '用户表';
  50. $this->start();
  51. }
  52. }