OwnerStoragePriceModelFactory.php 993 B

12345678910111213141516171819202122
  1. <?php
  2. /** @var \Illuminate\Database\Eloquent\Factory $factory */
  3. use App\OwnerStoragePriceModel;
  4. use Faker\Generator as Faker;
  5. $unit = \App\Unit::query()->first();
  6. $factory->define(OwnerStoragePriceModel::class, function (Faker $faker) use(&$unit){
  7. if (!$unit) $unit = \App\Unit::query()->first();
  8. $counting_type = ['包仓','灵活用仓','统单价'];
  9. $using_type = ['常温','恒温'];
  10. $discount_type = ['无减免','按单减免','固定减免'];
  11. return [
  12. "counting_type" => array_rand($counting_type), //计费类型
  13. "using_type" => array_rand($using_type), //用仓类型
  14. "minimum_area" => mt_rand(100,1000) / 50, //最低起租面积
  15. "price" => mt_rand(1,20) / 10, //单价
  16. "discount_type" => array_rand($discount_type), //减免类型
  17. "discount_value" => mt_rand(0,10) / 12, //减免值
  18. "unit_id" => $unit ? $unit->id : factory(\App\Unit::class), //单位ID
  19. ];
  20. });