mirror of
https://gitlab.com/izyim/prototypes/lumen-microservices/microservice-orders-api.git
synced 2026-08-19 04:24:05 +00:00
initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of your model factories. Model factories give
|
||||
| you a convenient way to create models for testing and seeding your
|
||||
| database. Just tell the factory how a default model should look.
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(App\Order::class, function (Faker\Generator $faker) {
|
||||
$quantity = $faker->numberBetween(1, 10);
|
||||
return [
|
||||
'quantity' => $quantity,
|
||||
'discount' => $faker->numberBetween(1, 30),
|
||||
'total_price' => ($quantity * $faker->numberBetween(1, 200)),
|
||||
'product_id' => $faker->numberBetween(1, 50),
|
||||
];
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateOrdersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('orders', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('quantity')->unsigned();
|
||||
$table->decimal('total_price')->unsigned();
|
||||
$table->decimal('discount')->unsigned()->default(0);
|
||||
$table->integer('product_id')->unsigned();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('orders');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
factory(\App\Order::class, 150)->create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user