first(); $model = \App\OwnerStoragePriceModel::query()->first(); $group = \App\UserOwnerGroup::query()->first(); $factory->define(OwnerAreaReport::class, function (Faker $faker)use($owner,$model,$group) { if (!$owner)$owner = \App\Owner::query()->first(); if (!$model)$model = \App\OwnerStoragePriceModel::query()->first(); if (!$group)$group = \App\UserOwnerGroup::query()->first(); $status = ['编辑中','已完成',"编辑中","编辑中"]; return [ "owner_id" => $owner ? $owner->id : factory(\App\Owner::class), //货主ID "counting_month" => $faker->date(), //结算月 "owner_storage_price_model_id" => $model ? $model->id : factory(\App\OwnerStoragePriceModel::class), //仓储计费ID "user_owner_group_id" => $group ? $group->id : factory(\App\UserOwnerGroup::class), //项目组ID "area_on_tray" => mt_rand(5,1000) / 6, //货物整托 "area_on_half_tray" => mt_rand(5,1000) / 6, //货物半托 "area_on_flat" => mt_rand(5,1000) / 6, //平面区面积 "accounting_area" => mt_rand(50,10000) / 6, //结算面积 "status" => $status[array_rand($status)] //状态 ]; });