Hocam ilginiz için teşekkür ederim öncelikle
<?php
use Faker\Generator as Faker;
use Modules\Product\Entities\Product;
$factory->define(Product::class, function (Faker $faker) {
return [
'name' => $name = $faker->name,
'slug' => str_slug($name),
'uuid' => $faker->uuid,
'is_slider' =>1,
'category_id' => 1,
'price' => 1000,
'discount' => 5,
'stock' => 5,
'description' => $faker->sentences(5),
'paragraph'=> $faker->sentence(5),
'h_tag' => $name,
'button_text'=> 'Shop Now',
];
});
Burada kullanılan sahte bilgiler bunlar description ve paragraph colonları text formatında uuid ise uuid formatında dır
test case ise şu şekilde
public function test_it_has_many_variations(){
$product = factory(Product::class)->create();
$product->variations()->save(
factory(ProductVariation::class)->create()
);
$this->assertInstanceOf(ProductVariation::class, $product->variations->first());
}
Relation da şöyle
public function variations(){
return $this->hasMany(ProductVariation::class)->orderBy('order', 'asc');
}
Teşekkürler yeniden