diff --git a/app/Models/Spell.php b/app/Models/Spell.php new file mode 100644 index 0000000..f1bb5f5 --- /dev/null +++ b/app/Models/Spell.php @@ -0,0 +1,39 @@ +slug = Str::slug($spell->name); + }); + } + + public function recipe() + { + return $this->hasOne(Recipe::class); + } +} diff --git a/database/factories/SpellFactory.php b/database/factories/SpellFactory.php new file mode 100644 index 0000000..db635df --- /dev/null +++ b/database/factories/SpellFactory.php @@ -0,0 +1,34 @@ + $this->faker->unique()->randomNumber(5), + 'name' => $this->faker->unique()->sentence(8), + 'slug' => function (array $attributes) { + return Str::slug($attributes['name']); + } + ]; + } +} diff --git a/tests/Feature/Models/SpellTest.php b/tests/Feature/Models/SpellTest.php new file mode 100644 index 0000000..73c1111 --- /dev/null +++ b/tests/Feature/Models/SpellTest.php @@ -0,0 +1,29 @@ +create(); + $recipe = Recipe::factory() + ->for($spell) + ->create(); + + $this->assertEquals($recipe->name, $spell->recipe->name); + } +}