MigrationBikesCommand.php 1002 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\Bike;
  4. use App\Models\BoxBinding;
  5. use Illuminate\Console\Command;
  6. use Illuminate\Support\Facades\DB;
  7. class MigrationBikesCommand extends Command
  8. {
  9. /**
  10. * The name and signature of the console command.
  11. *
  12. * @var string
  13. */
  14. protected $signature = 'migration:bikes';
  15. /**
  16. * The console command description.
  17. *
  18. * @var string
  19. */
  20. protected $description = '迁移车辆';
  21. /**
  22. * Create a new command instance.
  23. *
  24. * @return void
  25. */
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. }
  30. /**
  31. * Execute the console command.
  32. *
  33. * @return mixed
  34. */
  35. public function handle()
  36. {
  37. $bikes = Bike::where('bike_no', '<=', '10010010002')->where('bike_no', '>=', '10010010001')->get();
  38. $boxs = BoxBinding::where('box_no', 'in', $bikes->pluck('box_no'))->get();
  39. $this->line(count($bikes).'=='.count($boxs));
  40. }
  41. }