Category: Projects
Topic: Mini Ecommerce
Created: 3 years ago
// artisan command for migration, factory and seeder file
php artisan make:model FrameWidth -mfs
// migration file
public function up()
{
Schema::create('frame_widths', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->integer('percentage');
$table->integer('sequence');
$table->timestamps();
});
}
// FrameWidthFactory.php file
class FrameWidthFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array
*/
private static $order = 1;
public function definition()
{
return [
'name' => $this->faker->text(50),
'percentage' => rand(0,15),
'sequence' => self::$order++
];
}
}
// FrameWidthSeeder.php file
public function run()
{
//
FrameWidth::factory(5)->create();
}