osb/database/factories/ProductFactory.php

64 lines
2.0 KiB
PHP

<?php
use Faker\Generator as Faker;
$factory->define(App\Models\Product::class, function (Faker $faker) {
return [
'id'=>1,
'site_id'=>1,
'taxable'=>1,
'price_group'=>serialize([
1=>[
0=>[
'price_setup'=>50,
'price_base'=>100,
]
]
]),
];
});
$factory->state(App\Models\Product::class,'active',[
'active' => 1,
]);
$factory->state(App\Models\Product::class,'strict',[
'price_recurr_strict' => 1,
]);
$factory->state(App\Models\Product::class,'notstrict',[
'price_recurr_strict' => 0,
]);
$factory->afterMakingState(App\Models\Product::class,'broadband-unlimit',function ($product,$faker) {
$type = factory(App\Models\Product\Adsl::class)->state('unlimit')->make();
$product->setRelation('type',$type);
$product->prod_plugin_data = $type->id;
$product->model = 'App\Models\Product\Adsl';
});
$factory->afterMakingState(App\Models\Product::class,'broadband-140/0/0/0',function ($product,$faker) {
$type = factory(App\Models\Product\Adsl::class)->state('140/0/0/0')->make();
$product->setRelation('type',$type);
$product->prod_plugin_data = $type->id;
$product->model = 'App\Models\Product\Adsl';
});
$factory->afterMakingState(App\Models\Product::class,'broadband-70/-/0/-',function ($product,$faker) {
$type = factory(App\Models\Product\Adsl::class)->state('70/-/0/-')->make();
$product->setRelation('type',$type);
$product->prod_plugin_data = $type->id;
$product->model = 'App\Models\Product\Adsl';
});
$factory->afterMakingState(App\Models\Product::class,'broadband-100/0/40/0',function ($product,$faker) {
$type = factory(App\Models\Product\Adsl::class)->state('100/0/40/0')->make();
$product->setRelation('type',$type);
$product->prod_plugin_data = $type->id;
$product->model = 'App\Models\Product\Adsl';
});
$factory->afterMakingState(App\Models\Product::class,'broadband-50/-/20/-',function ($product,$faker) {
$type = factory(App\Models\Product\Adsl::class)->state('50/-/20/-')->make();
$product->setRelation('type',$type);
$product->prod_plugin_data = $type->id;
$product->model = 'App\Models\Product\Adsl';
});