OwnerAreaReportFactory.php 1.3 KB

123456789101112131415161718192021222324252627
  1. <?php
  2. /** @var \Illuminate\Database\Eloquent\Factory $factory */
  3. use App\OwnerAreaReport;
  4. use Faker\Generator as Faker;
  5. $owner = \App\Owner::query()->first();
  6. $model = \App\OwnerStoragePriceModel::query()->first();
  7. $group = \App\UserOwnerGroup::query()->first();
  8. $factory->define(OwnerAreaReport::class, function (Faker $faker)use($owner,$model,$group) {
  9. if (!$owner)$owner = \App\Owner::query()->first();
  10. if (!$model)$model = \App\OwnerStoragePriceModel::query()->first();
  11. if (!$group)$group = \App\UserOwnerGroup::query()->first();
  12. $status = ['编辑中','已完成',"编辑中","编辑中"];
  13. return [
  14. "owner_id" => $owner ? $owner->id : factory(\App\Owner::class), //货主ID
  15. "counting_month" => $faker->date(), //结算月
  16. "owner_storage_price_model_id" => $model ? $model->id : factory(\App\OwnerStoragePriceModel::class), //仓储计费ID
  17. "user_owner_group_id" => $group ? $group->id : factory(\App\UserOwnerGroup::class), //项目组ID
  18. "area_on_tray" => mt_rand(5,1000) / 6, //货物整托
  19. "area_on_half_tray" => mt_rand(5,1000) / 6, //货物半托
  20. "area_on_flat" => mt_rand(5,1000) / 6, //平面区面积
  21. "accounting_area" => mt_rand(50,10000) / 6, //结算面积
  22. "status" => $status[array_rand($status)] //状态
  23. ];
  24. });