diff options
author | Sam Light <samlight1994@gmail.com> | 2025-01-18 20:17:47 +0000 |
---|---|---|
committer | Sam Light <samlight1994@gmail.com> | 2025-01-18 20:17:47 +0000 |
commit | eb5c48b58d72d04abb093fceb32db842ec7ab5fb (patch) | |
tree | 4cf40914cba238a46dbb99c36d83e2dfb4efc3e0 /workbench/database | |
parent | 7ae6611fbcee86e6dae9890c27da329fa036717f (diff) |
Setup testing
Diffstat (limited to 'workbench/database')
3 files changed, 83 insertions, 0 deletions
diff --git a/workbench/database/factories/ProductFactory.php b/workbench/database/factories/ProductFactory.php new file mode 100644 index 0000000..4131cb2 --- /dev/null +++ b/workbench/database/factories/ProductFactory.php @@ -0,0 +1,33 @@ +<?php + +namespace Workbench\Database\Factories; + +use Illuminate\Database\Eloquent\Factories\Factory; +use Workbench\App\Models\Product; + +/** + * @template TModel of \Workbench\App\Models\Product + * + * @extends \Illuminate\Database\Eloquent\Factories\Factory<TModel> + */ +class ProductFactory extends Factory +{ + /** + * The name of the factory's corresponding model. + * + * @var class-string<TModel> + */ + protected $model = Product::class; + + /** + * Define the model's default state. + * + * @return array<string, mixed> + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/workbench/database/migrations/2025_01_18_201725_create_products_table.php b/workbench/database/migrations/2025_01_18_201725_create_products_table.php new file mode 100644 index 0000000..7c23f58 --- /dev/null +++ b/workbench/database/migrations/2025_01_18_201725_create_products_table.php @@ -0,0 +1,27 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +return new class extends Migration +{ + /** + * Run the migrations. + */ + public function up(): void + { + Schema::create('products', function (Blueprint $table) { + $table->id(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('products'); + } +}; diff --git a/workbench/database/seeders/DatabaseSeeder.php b/workbench/database/seeders/DatabaseSeeder.php new file mode 100644 index 0000000..f10adbb --- /dev/null +++ b/workbench/database/seeders/DatabaseSeeder.php @@ -0,0 +1,23 @@ +<?php + +namespace Workbench\Database\Seeders; + +use Illuminate\Database\Seeder; +// use Illuminate\Database\Console\Seeds\WithoutModelEvents; +use Workbench\Database\Factories\UserFactory; + +class DatabaseSeeder extends Seeder +{ + /** + * Seed the application's database. + */ + public function run(): void + { + // UserFactory::new()->times(10)->create(); + + UserFactory::new()->create([ + 'name' => 'Test User', + 'email' => 'test@example.com', + ]); + } +} |