adding products

This commit is contained in:
2026-04-09 16:35:18 -06:00
parent 53af097928
commit 0ca7b94cc0
7 changed files with 123 additions and 3 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace Database\Factories;
use App\Models\Product;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Product>
*/
class ProductFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->words(3, true),
'description' => $this->faker->sentence(12),
'price_cents' => $this->faker->numberBetween(499, 9999),
];
}
}
@@ -0,0 +1,30 @@
<?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->string('name');
$table->text('description');
$table->unsignedInteger('price_cents');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('products');
}
};
+1
View File
@@ -2,6 +2,7 @@
namespace Database\Seeders;
use App\Models\Product;
use App\Models\User;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;