-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from shaffe-fr/feature/relations
Support relations stack & foreign relations
- Loading branch information
Showing
6 changed files
with
180 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
example/database/migrations/2020_06_09_0000_create_ingredient_recipe_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
class CreateIngredientRecipeTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('ingredient_recipe', function (Blueprint $table) { | ||
$table->unsignedBigInteger('ingredient_id'); | ||
$table->unsignedBigInteger('recipe_id'); | ||
$table->primary(['ingredient_id', 'recipe_id']); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::drop('ingredient_recipe'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace ExampleAppTests\Factories; | ||
|
||
use Christophrumpel\LaravelFactoriesReloaded\BaseFactory; | ||
use ExampleApp\Models\Ingredient; | ||
use Faker\Generator; | ||
|
||
class IngredientFactory extends BaseFactory | ||
{ | ||
protected string $modelClass = Ingredient::class; | ||
|
||
public function create(array $extra = []): Ingredient | ||
{ | ||
return parent::build($extra); | ||
} | ||
|
||
public function make(array $extra = []): Ingredient | ||
{ | ||
return parent::build($extra, 'make'); | ||
} | ||
|
||
public function getDefaults(Generator $faker): array | ||
{ | ||
return [ | ||
'name' => 'Pasta', | ||
'description' => 'Good pasta!', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters